commit 2392a32a5c57acaa7c17a0a7bc19781f091d35fc
parent a5727122d59505a22ff88465ae58315bda10847b
Author: Michael Rasmussen <mir@datanom.net>
Date: Tue, 3 Jul 2012 21:33:32 +0000
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)
Diffstat:
5 files changed, 60 insertions(+), 25 deletions(-)
diff --git 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
diff --git a/PATCHSETS b/PATCHSETS
@@ -4377,3 +4377,5 @@
( 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
diff --git a/configure.ac b/configure.ac
@@ -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=
diff --git a/src/common/defs.h b/src/common/defs.h
@@ -148,6 +148,9 @@
#define BUFFSIZE 8192
+/* according to RFC 821 1000 characters including CRLF */
+#define MAXSMTPTEXTLEN 1000
+
#ifndef MAXPATHLEN
# define MAXPATHLEN 4095
#endif
diff --git a/src/procmime.c b/src/procmime.c
@@ -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;
}
}