2008-11-25 [colin] 3.6.1cvs42
authorColin Leroy <colin@colino.net>
Tue, 25 Nov 2008 16:43:26 +0000 (16:43 +0000)
committerColin Leroy <colin@colino.net>
Tue, 25 Nov 2008 16:43:26 +0000 (16:43 +0000)
* src/procmime.c
Fix line length in MIME parameters

ChangeLog
PATCHSETS
configure.ac
src/procmime.c

index d93add58965de1205be4e9b05784e6acbd1fc5e8..d7c6acb342c6818b55cb8c37560290eb5501f944 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-25 [colin]     3.6.1cvs42
+
+       * src/procmime.c
+               Fix line length in MIME parameters
+
 2008-11-22 [paul]      3.6.1cvs41
 
        * src/compose.c
 2008-11-22 [paul]      3.6.1cvs41
 
        * src/compose.c
index b449ebdf19bb35ccd455c17d543c95b940feb7a5..c459504e615f91d81fca7756859d6af921d509e1 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.13.2.41 -r 1.13.2.42 src/common/socket.c;  ) > 3.6.1cvs39.patchset
 ( cvs diff -u -r 1.382.2.486 -r 1.382.2.487 src/compose.c;  cvs diff -u -r 1.49.2.120 -r 1.49.2.121 src/procmime.c;  ) > 3.6.1cvs40.patchset
 ( cvs diff -u -r 1.382.2.487 -r 1.382.2.488 src/compose.c;  ) > 3.6.1cvs41.patchset
 ( cvs diff -u -r 1.13.2.41 -r 1.13.2.42 src/common/socket.c;  ) > 3.6.1cvs39.patchset
 ( cvs diff -u -r 1.382.2.486 -r 1.382.2.487 src/compose.c;  cvs diff -u -r 1.49.2.120 -r 1.49.2.121 src/procmime.c;  ) > 3.6.1cvs40.patchset
 ( cvs diff -u -r 1.382.2.487 -r 1.382.2.488 src/compose.c;  ) > 3.6.1cvs41.patchset
+( cvs diff -u -r 1.49.2.121 -r 1.49.2.122 src/procmime.c;  ) > 3.6.1cvs42.patchset
index f93b42d9d3f08dfc564fe8ec999f11477002fa42..365f55dd485c96aee690404282a7a0af38069bfe 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=6
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=41
+EXTRA_VERSION=42
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index e2358922e264060e33f12056afa37b97509d6ae0..951fdd8ea134ad8630fb0c03b36c39fc81cc94db 100644 (file)
@@ -2111,7 +2111,7 @@ typedef enum {
     ENC_AS_TOKEN,
     ENC_AS_QUOTED_STRING,
     ENC_AS_EXTENDED,
     ENC_AS_TOKEN,
     ENC_AS_QUOTED_STRING,
     ENC_AS_EXTENDED,
-    ENC_AS_B64
+    ENC_AS_ENCWORD
 } EncodeAs;
 
 typedef struct _ParametersData {
 } EncodeAs;
 
 typedef struct _ParametersData {
@@ -2132,7 +2132,7 @@ static void write_parameters(gpointer key, gpointer value, gpointer user_data)
 
        for (valpos = val; *valpos != 0; valpos++) {
                if (!IS_ASCII(*valpos)) {
 
        for (valpos = val; *valpos != 0; valpos++) {
                if (!IS_ASCII(*valpos)) {
-                       encas = ENC_AS_B64;
+                       encas = ENC_AS_ENCWORD;
                        break;
                }
            
                        break;
                }
            
@@ -2192,18 +2192,42 @@ static void write_parameters(gpointer key, gpointer value, gpointer user_data)
                }
                break;          
 
                }
                break;          
 
-       case ENC_AS_B64:
-               len = strlen(val)*6;
+       case ENC_AS_ENCWORD:
+               len = MAX(strlen(val)*6, 512);
                tmp = g_malloc(len+1);
                tmp = g_malloc(len+1);
-               base64_encode(tmp, val, strlen(val));
-               g_string_append_printf(buf, "%s=\"=?UTF-8?B?%s?=\"", param, tmp);
+               codeconv_set_strict(TRUE);
+               conv_encode_header_full(tmp, len, val, pdata->len + strlen(param) + 4 , FALSE,
+                       prefs_common.outgoing_charset);
+               codeconv_set_strict(FALSE);
+               if (!tmp || !*tmp) {
+                       codeconv_set_strict(TRUE);
+                       conv_encode_header_full(tmp, len, val, pdata->len + strlen(param) + 4 , FALSE,
+                               conv_get_outgoing_charset_str());
+                       codeconv_set_strict(FALSE);
+               }
+               if (!tmp || !*tmp) {
+                       codeconv_set_strict(TRUE);
+                       conv_encode_header_full(tmp, len, val, pdata->len + strlen(param) + 4 , FALSE,
+                               CS_UTF_8);
+                       codeconv_set_strict(FALSE);
+               }
+               if (!tmp || !*tmp) {
+                       conv_encode_header_full(tmp, len, val, pdata->len + strlen(param) + 4 , FALSE,
+                               CS_UTF_8);
+               }
+               g_string_append_printf(buf, "%s=\"%s\"", param, tmp);
                g_free(tmp);
                break;
 
        }
        
        if (buf->str && strlen(buf->str)) {
                g_free(tmp);
                break;
 
        }
        
        if (buf->str && strlen(buf->str)) {
-               if (pdata->len + strlen(buf->str) + 2 > 76) {
+               tmp = strstr(buf->str, "\n");
+               if (tmp)
+                       len = (tmp - buf->str);
+               else
+                       len = strlen(buf->str);
+               if (pdata->len + len > 76) {
                        if (fprintf(pdata->fp, ";\n %s", buf->str) < 0)
                                pdata->error = TRUE;
                        pdata->len = strlen(buf->str) + 1;
                        if (fprintf(pdata->fp, ";\n %s", buf->str) < 0)
                                pdata->error = TRUE;
                        pdata->len = strlen(buf->str) + 1;