sycn with 0.8.8cvs11
authorPaul Mangan <paul@claws-mail.org>
Fri, 17 Jan 2003 09:59:47 +0000 (09:59 +0000)
committerPaul Mangan <paul@claws-mail.org>
Fri, 17 Jan 2003 09:59:47 +0000 (09:59 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.ac
src/common/quoted-printable.c
src/common/utils.c
src/common/utils.h
src/compose.c
src/procmime.c
src/procmsg.c

index 046092e..2e469ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2003-01-17
+
+       * src/quoted-printable.c: qp_encode_line(): fixed linebreak
+         duplication bug if the source string has CRLF.
+       * src/utils.[ch]:
+         canonicalize_str(): new. Returns newly allocated canonicalized
+         string.
+         uncanonicalize_file(): new. Uncanonicalize (CRLF -> LF) text.
+         uncanonicalize_file_replace(): new.
+       * src/compose.c: always canonicalize body before processing, and
+         uncanonicalize before returning.
+
+2003-01-17
+
+       * src/procmime.c: procmime_get_encoding_for_charset(): prefer
+         ENC_8BIT for Russian charsets.
+       * src/compose.c: compose_write_to_file(): use base64 when signing
+         8bit message.
+
 2003-01-16
 
        * src/prefs_common.c: prefs_send_create(): added a description for
index bb485f8..5f47333 100644 (file)
@@ -1,3 +1,8 @@
+2003-01-17 [paul]      0.8.8claws108
+
+       * sync with 0.8.8cvs11
+               see ChangeLog 2003-01-17
+
 2003-01-16 [colin]     0.8.8claws107
 
        * src/procmsg.c
index 5c726fa..ae2e4e8 100644 (file)
@@ -1,3 +1,22 @@
+2003-01-17
+
+       * src/quoted-printable.c: qp_encode_line(): ¸µ¤Îʸ»úÎó¤Ë CRLF ¤¬
+         ¤¢¤Ã¤¿¾ì¹ç¤Ë²þ¹Ô¤¬½ÅÊ£¤¹¤ë¥Ð¥°¤ò½¤Àµ¡£
+       * src/utils.[ch]
+         canonicalize_str(): ¿·µ¬¡£¿·µ¬¤Ë³ÎÊݤµ¤ì¤¿Àµµ¬²½¤µ¤ì¤¿Ê¸»úÎó¤ò
+         ÊÖ¤¹¡£
+         uncanonicalize_file(): ¿·µ¬¡£Àµµ¬²½¤ò²ò½ü¤¹¤ë(CRLF -> LF)¡£
+         uncanonicalize_file_replace(): ¿·µ¬¡£
+       * src/compose.c: ½èÍý¤ÎÁ°¤Ë¾ï¤ËËÜʸ¤òÀµµ¬²½¤·¡¢Ìá¤ëÁ°¤ËÀµµ¬²½¤ò
+         ²ò½ü¤¹¤ë¤è¤¦¤Ë¤·¤¿¡£
+
+2003-01-17
+
+       * src/procmime.c: procmime_get_encoding_for_charset(): ¥í¥·¥¢¸ì
+         charset ¤Î¾ì¹ç¤Ï ENC_8BIT ¤òÁª¤Ö¤è¤¦¤Ë¤·¤¿¡£
+       * src/compose.c: compose_write_to_file(): 8bit ¥á¥Ã¥»¡¼¥¸¤ò½ð̾¤¹¤ë
+         ¾ì¹ç¤Ï base64 ¤ò»ÈÍѤ¹¤ë¤è¤¦¤Ë¤·¤¿¡£
+
 2003-01-16
 
        * src/prefs_common.c: prefs_send_create(): Content-Transfer-Encoding
index 8a32fe9..47a7470 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws107
+EXTRA_VERSION=claws108
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 515641b..7e8da23 100644 (file)
@@ -49,6 +49,8 @@ void qp_encode_line(gchar *out, const guchar *in)
                if (IS_LBREAK(inp)) {
                        *outp++ = '\n';
                        len = 0;
+                       if (*inp == '\r')
+                               inp++;
                        inp++;
                } else if (ch == '\t' || ch == ' ') {
                        if (IS_LBREAK(inp + 1)) {
index 4e5d79e..ab112f2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -2321,6 +2321,39 @@ gint copy_file_part(FILE *fp, off_t offset, size_t length, const gchar *dest)
 /* convert line endings into CRLF. If the last line doesn't end with
  * linebreak, add it.
  */
+gchar *canonicalize_str(const gchar *str)
+{
+       const gchar *p;
+       guint new_len = 0;
+       gchar *out, *outp;
+
+       for (p = str; *p != '\0'; ++p) {
+               if (*p != '\r') {
+                       ++new_len;
+                       if (*p == '\n')
+                               ++new_len;
+               }
+       }
+       if (p == str || *(p - 1) != '\n')
+               new_len += 2;
+
+       out = outp = g_malloc(new_len + 1);
+       for (p = str; *p != '\0'; ++p) {
+               if (*p != '\r') {
+                       if (*p == '\n')
+                               *outp++ = '\r';
+                       *outp++ = *p;
+               }
+       }
+       if (p == str || *(p - 1) != '\n') {
+               *outp++ = '\r';
+               *outp++ = '\n';
+       }
+       *outp = '\0';
+
+       return out;
+}
+
 gint canonicalize_file(const gchar *src, const gchar *dest)
 {
        FILE *src_fp, *dest_fp;
@@ -2382,7 +2415,7 @@ gint canonicalize_file(const gchar *src, const gchar *dest)
        }
 
        if (ferror(src_fp)) {
-               FILE_OP_ERROR(src, "fread");
+               FILE_OP_ERROR(src, "fgets");
                err = TRUE;
        }
        fclose(src_fp);
@@ -2421,6 +2454,79 @@ gint canonicalize_file_replace(const gchar *file)
        return 0;
 }
 
+gint uncanonicalize_file(const gchar *src, const gchar *dest)
+{
+       FILE *src_fp, *dest_fp;
+       gchar buf[BUFFSIZE];
+       gboolean err = FALSE;
+
+       if ((src_fp = fopen(src, "rb")) == NULL) {
+               FILE_OP_ERROR(src, "fopen");
+               return -1;
+       }
+
+       if ((dest_fp = fopen(dest, "wb")) == NULL) {
+               FILE_OP_ERROR(dest, "fopen");
+               fclose(src_fp);
+               return -1;
+       }
+
+       if (change_file_mode_rw(dest_fp, dest) < 0) {
+               FILE_OP_ERROR(dest, "chmod");
+               g_warning("can't change file mode\n");
+       }
+
+       while (fgets(buf, sizeof(buf), src_fp) != NULL) {
+               strcrchomp(buf);
+               if (fputs(buf, dest_fp) == EOF) {
+                       g_warning("writing to %s failed.\n", dest);
+                       fclose(dest_fp);
+                       fclose(src_fp);
+                       unlink(dest);
+                       return -1;
+               }
+       }
+
+       if (ferror(src_fp)) {
+               FILE_OP_ERROR(src, "fgets");
+               err = TRUE;
+       }
+       fclose(src_fp);
+       if (fclose(dest_fp) == EOF) {
+               FILE_OP_ERROR(dest, "fclose");
+               err = TRUE;
+       }
+
+       if (err) {
+               unlink(dest);
+               return -1;
+       }
+
+       return 0;
+}
+
+gint uncanonicalize_file_replace(const gchar *file)
+{
+       gchar *tmp_file;
+
+       tmp_file = get_tmp_file();
+
+       if (uncanonicalize_file(file, tmp_file) < 0) {
+               g_free(tmp_file);
+               return -1;
+       }
+
+       if (move_file(tmp_file, file, TRUE) < 0) {
+               g_warning("can't replace %s .\n", file);
+               unlink(tmp_file);
+               g_free(tmp_file);
+               return -1;
+       }
+
+       g_free(tmp_file);
+       return 0;
+}
+
 gint change_file_mode_rw(FILE *fp, const gchar *file)
 {
 #if HAVE_FCHMOD
index 2c77192..dcb59de 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -356,9 +356,15 @@ gint copy_file_part                (FILE           *fp,
                                 off_t           offset,
                                 size_t          length,
                                 const gchar    *dest);
+
+gchar *canonicalize_str                (const gchar    *str);
 gint canonicalize_file         (const gchar    *src,
                                 const gchar    *dest);
 gint canonicalize_file_replace (const gchar    *file);
+gint uncanonicalize_file       (const gchar    *src,
+                                const gchar    *dest);
+gint uncanonicalize_file_replace(const gchar   *file);
+
 gint change_file_mode_rw       (FILE           *fp,
                                 const gchar    *file);
 FILE *my_tmpfile               (void);
index 40cf24d..165519e 100644 (file)
@@ -3180,8 +3180,7 @@ static gint compose_clearsign_text(Compose *compose, gchar **text)
                return -1;
        }
 
-       if (canonicalize_file_replace(tmp_file) < 0 ||
-           compose_create_signers_list(compose, &key_list) < 0 ||
+       if (compose_create_signers_list(compose, &key_list) < 0 ||
            rfc2015_clearsign(tmp_file, key_list) < 0) {
                unlink(tmp_file);
                g_free(tmp_file);
@@ -3206,6 +3205,7 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
        size_t len;
        gchar *chars;
        gchar *buf;
+       gchar *canon_buf;
        const gchar *out_codeset;
        EncodingType encoding;
 
@@ -3248,7 +3248,7 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
                if (!is_draft &&
                    compose->use_signing && !compose->gnupg_mode &&
                    encoding == ENC_8BIT)
-                       encoding = ENC_QUOTED_PRINTABLE;
+                       encoding = ENC_BASE64;
 #endif
 
                src_codeset = conv_get_current_charset_str();
@@ -3281,33 +3281,9 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
        }
        g_free(chars);
 
-       /* Canonicalize line endings in the message text */
-       {
-               gchar *canon_buf, *out;
-               const gchar *p;
-               guint new_len = 0;
-
-               for (p = buf ; *p; ++p) {
-                       if (*p != '\r') {
-                               ++new_len;
-                               if (*p == '\n')
-                                       ++new_len;
-                       }
-               }
-
-               out = canon_buf = g_new(gchar, new_len + 1);
-               for (p = buf; *p; ++p) {
-                       if (*p != '\r') {
-                               if (*p == '\n')
-                                       *out++ = '\r';
-                               *out++ = *p;
-                       }
-               }
-               *out = '\0';
-
-               free(buf);
-               buf = canon_buf;
-       }
+       canon_buf = canonicalize_str(buf);
+       g_free(buf);
+       buf = canon_buf;
 
 #if USE_GPGME
        if (!is_draft && compose->use_signing && compose->gnupg_mode) {
@@ -3395,8 +3371,10 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
        }
 
 #if USE_GPGME
-       if (is_draft)
+       if (is_draft) {
+               uncanonicalize_file_replace(file);
                return 0;
+       }
 
        if ((compose->use_signing && !compose->gnupg_mode) ||
            compose->use_encryption) {
@@ -3424,6 +3402,8 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
        }
 #endif /* USE_GPGME */
 
+       uncanonicalize_file_replace(file);
+
        return 0;
 }
 
index 7aedcc3..97585cc 100644 (file)
@@ -1241,7 +1241,7 @@ EncodingType procmime_get_encoding_for_charset(const gchar *charset)
        else if (!strcasecmp(charset, "ISO-8859-5") ||
                 !strncasecmp(charset, "KOI8-", 5) ||
                 !strcasecmp(charset, "Windows-1251"))
-               return ENC_BASE64;
+               return ENC_8BIT;
        else if (!strncasecmp(charset, "ISO-8859-", 9))
                return ENC_QUOTED_PRINTABLE;
        else
index 50278cf..11180f2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by