[Commits] procmime.c 1.49.2.143 1.49.2.144

miras at claws-mail.org miras at claws-mail.org
Tue Jul 3 23:33:34 CEST 2012


Update of /home/claws-mail/claws/src
In directory srv:/tmp/cvs-serv28095/src

Modified Files:
      Tag: gtk2
	procmime.c 
Log Message:
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)

Index: procmime.c
===================================================================
RCS file: /home/claws-mail/claws/src/procmime.c,v
retrieving revision 1.49.2.143
retrieving revision 1.49.2.144
diff -u -d -r1.49.2.143 -r1.49.2.144
--- procmime.c	3 Jul 2012 17:23:00 -0000	1.49.2.143
+++ procmime.c	3 Jul 2012 21:33:32 -0000	1.49.2.144
@@ -562,29 +562,16 @@
 			g_free(tmp_file);
 		}
 	} else if (encoding == ENC_QUOTED_PRINTABLE) {
-		gchar inbuf[79], outbuf[77];
-		gint n, len = 0;
-		gboolean firstrun = TRUE;
-
-		while ((len += fread(inbuf + len, 1,
-			sizeof(inbuf) - len - 1,
-			infp)) > 0)
-		{
-			if (firstrun == FALSE)
-				if (fputs("\r\n", outfp) == EOF)
-					err = TRUE;
+		gchar inbuf[BUFFSIZE], outbuf[BUFFSIZE * 4];
 
-			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 @@
 				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;
 		}
 	}
 



More information about the Commits mailing list