2012-07-03 [mir] 3.8.1cvs4
authorMichael Rasmussen <mir@datanom.net>
Tue, 3 Jul 2012 21:33:32 +0000 (21:33 +0000)
committerMichael Rasmussen <mir@datanom.net>
Tue, 3 Jul 2012 21:33:32 +0000 (21:33 +0000)
* src/procmime.c
* src/common/defs.h
            fix bug 2641, '7bit or 8bit encoded attachments can
            have lines longer than 998 characters'.
            Patch provided by Christopher Zimmermann
            (madroach claws at gmerlin dot de)

ChangeLog
PATCHSETS
configure.ac
src/common/defs.h
src/procmime.c

index 4b84e13..a5ce9c4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2012-07-03 [mir]       3.8.1cvs4
+
+       * src/procmime.c
+       * src/common/defs.h
+            fix bug 2641, '7bit or 8bit encoded attachments can
+            have lines longer than 998 characters'.
+            Patch provided by Christopher Zimmermann
+            (madroach claws at gmerlin dot de)
+
+
+2012-07-03 [mir]       3.8.1cvs3
+
+       * src/procmime.c
+       * src/common/defs.h
+           fix bug 2641, '7bit or 8bit encoded attachments can
+           have lines longer than 998 characters'.
+           Patch provided by Christopher Zimmermann
+           (madroach claws at gmerlin dot de)
+
 2012-07-03 [mir]       3.8.1cvs2
 
        * src/messageview.c
index 0930569..fc110fb 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.654.2.4452 -r 1.654.2.4453 configure.ac;  ) > 3.8.0cvs58.patchset
 ( cvs diff -u -r 1.24.2.29 -r 1.24.2.30 Makefile.am;  ) > 3.8.1cvs1.patchset
 ( cvs diff -u -r 1.94.2.233 -r 1.94.2.234 src/messageview.c;  cvs diff -u -r 1.49.2.142 -r 1.49.2.143 src/procmime.c;  cvs diff -u -r 1.3.2.17 -r 1.3.2.18 src/common/quoted-printable.c;  cvs diff -u -r 1.3.2.9 -r 1.3.2.10 src/common/quoted-printable.h;  ) > 3.8.1cvs2.patchset
+( cvs diff -u -r 1.49.2.143 -r 1.49.2.144 src/procmime.c;  cvs diff -u -r 1.9.2.54 -r 1.9.2.55 src/common/defs.h;  ) > 3.8.1cvs3.patchset
+( cvs diff -u -r 1.49.2.143 -r 1.49.2.144 src/procmime.c;  cvs diff -u -r 1.9.2.54 -r 1.9.2.55 src/common/defs.h;  ) > 3.8.1cvs4.patchset
index 096af30..8e2c3f3 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=8
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=2
+EXTRA_VERSION=4
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 409da55..d33eedb 100644 (file)
 
 #define BUFFSIZE                       8192
 
+/* according to RFC 821 1000 characters including CRLF */
+#define MAXSMTPTEXTLEN                 1000
+
 #ifndef MAXPATHLEN
 #  define MAXPATHLEN                   4095
 #endif
index 5bd3363..6b6659f 100644 (file)
@@ -562,29 +562,16 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
                        g_free(tmp_file);
                }
        } else if (encoding == ENC_QUOTED_PRINTABLE) {
-               gchar inbuf[79], outbuf[77];
-               gint n, len = 0;
-               gboolean firstrun = TRUE;
+               gchar inbuf[BUFFSIZE], outbuf[BUFFSIZE * 4];
 
-               while ((len += fread(inbuf + len, 1,
-                       sizeof(inbuf) - len - 1,
-                       infp)) > 0)
-               {
-                       if (firstrun == FALSE)
-                               if (fputs("\r\n", outfp) == EOF)
-                                       err = TRUE;
-
-                       inbuf[len] = '\0';
-                       n = qp_encode(mimeinfo->type == MIMETYPE_TEXT,
-                                       outbuf, inbuf, len);
-                       len -= n;
-                       memmove(inbuf, inbuf + n, len);
+               while (fgets(inbuf, sizeof(inbuf), infp) != NULL) {
+                       qp_encode_line(outbuf, inbuf);
 
                        if (!strncmp("From ", outbuf, sizeof("From ")-1)) {
                                gchar *tmpbuf = outbuf;
-
+                               
                                tmpbuf += sizeof("From ")-1;
-
+                               
                                if (fputs("=46rom ", outfp) == EOF)
                                        err = TRUE;
                                if (fputs(tmpbuf, outfp) == EOF)
@@ -593,15 +580,39 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
                                if (fputs(outbuf, outfp) == EOF)
                                        err = TRUE;
                        }
-                       firstrun = FALSE;
                }
        } else {
-               gchar buf[BUFFSIZE];
+               gchar buf[MAXSMTPTEXTLEN+1];
+               gint leftover = 0;
 
-               while (fgets(buf, sizeof(buf), infp) != NULL) {
-                       strcrchomp(buf);
-                       if (fputs(buf, outfp) == EOF)
-                               err = TRUE;
+               while (fgets(buf + leftover,
+                       sizeof(buf) - leftover,
+                       infp) != NULL)
+               {
+                   gchar *l, *c = buf;
+                   leftover = 0;
+                   
+                   while (*c != '\0') {
+                       if (
+                           *c == '\n'
+                           || (*c == '\r' && *(c+1) == '\n'))
+                       {
+                           *c = '\0';
+                           break;
+                       }
+                       c++;
+                   }
+                   while (c - buf > MAXSMTPTEXTLEN - 2) {
+                       *c = *(c-1);
+                       *--c = '\0';
+                       leftover++;
+                   }
+                   
+                   if (fputs(buf, outfp) == EOF || putc('\n', outfp) == EOF)
+                       err = TRUE;
+
+                   for (l = buf; l-buf < leftover; l++)
+                       *l = *++c;
                }
        }