[Commits] defs.h 1.9.2.57 1.9.2.58 quoted-printable.c 1.3.2.18 1.3.2.19 quoted-printable.h 1.3.2.10 1.3.2.11

claws at claws-mail.org claws at claws-mail.org
Tue Jul 10 23:13:09 CEST 2012


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

Modified Files:
      Tag: gtk2
	defs.h quoted-printable.c quoted-printable.h 
Log Message:
2012-07-10 [paul]	3.8.1cvs13

	* src/messageview.c
	* src/common/defs.h
	* src/common/quoted-printable.c
	* src/common/quoted-printable.h
		revert 3.8.1cvs2,3,4,5  because they (somewhere!) cause
		the bug: partial message text loss 

Index: defs.h
===================================================================
RCS file: /home/claws-mail/claws/src/common/defs.h,v
retrieving revision 1.9.2.57
retrieving revision 1.9.2.58
diff -u -d -r1.9.2.57 -r1.9.2.58
--- defs.h	7 Jul 2012 07:30:56 -0000	1.9.2.57
+++ defs.h	10 Jul 2012 21:13:07 -0000	1.9.2.58
@@ -148,9 +148,6 @@
 
 #define BUFFSIZE			8192
 
-/* according to RFC 821 1000 characters including CRLF */
-#define MAXSMTPTEXTLEN			1000
-
 #ifndef MAXPATHLEN
 #  define MAXPATHLEN			4095
 #endif

Index: quoted-printable.c
===================================================================
RCS file: /home/claws-mail/claws/src/common/quoted-printable.c,v
retrieving revision 1.3.2.18
retrieving revision 1.3.2.19
diff -u -d -r1.3.2.18 -r1.3.2.19
--- quoted-printable.c	3 Jul 2012 17:23:00 -0000	1.3.2.18
+++ quoted-printable.c	10 Jul 2012 21:13:07 -0000	1.3.2.19
@@ -22,81 +22,66 @@
 
 #include "utils.h"
 
-
 #define MAX_LINELEN	76
 
 #define IS_LBREAK(p) \
-	((p)[0] == '\n' ? 1 : ((p)[0] == '\r' && (p)[1] == '\n') ? 2 : 0)
+	(*(p) == '\0' || *(p) == '\n' || (*(p) == '\r' && *((p) + 1) == '\n'))
 
-gint qp_encode(gboolean text, gchar *out, const guchar *in, gint len)
+#define SOFT_LBREAK_IF_REQUIRED(n)					\
+	if (len + (n) > MAX_LINELEN ||					\
+	    (len + (n) == MAX_LINELEN && (!IS_LBREAK(inp + 1)))) {	\
+		*outp++ = '=';						\
+		*outp++ = '\n';						\
+		len = 0;						\
+	}
+
+void qp_encode_line(gchar *out, const guchar *in)
 {
-	/* counters of input/output characters */
-	gint inc = 0;
-	gint outc = 1; /* one character reserved for '=' soft line break */
+	const guchar *inp = in;
+	gchar *outp = out;
+	guchar ch;
+	gint len = 0;
 
-	while(inc < len) {
-		/* allow literal linebreaks in text */
-		if(text) {
-			if(IS_LBREAK(in)) {
-				/* inserting linebreaks is the job of our caller */
-				g_assert(outc <= MAX_LINELEN);
-				*out = '\0';
-				return inc + IS_LBREAK(in);
-			}
-			if(IS_LBREAK(in+1)) {
-				/* free the reserved character since no softbreak
-				 * will be needed after the current character */
-				outc--;
-				/* guard against whitespace before a literal linebreak */
-				if(*in == ' ' || *in == '\t') {
-					goto escape;
-				}
-			}
-		}
-		if(*in == '=') {
-			goto escape;
-		}
-		/* Cave: Whitespace is unconditionally output literally,
-		 * but according to the RFC it must not be output before a
-		 * linebreak. 
-		 * This requirement is obeyed by quoting all linebreaks
-		 * and therefore ending all lines with '='. */
-		else if((*in >= ' ' && *in <= '~') || *in == '\t') {
-			if(outc + 1 <= MAX_LINELEN) {
-				*out++ = *in++;
-				outc++;
-				inc++;
-			}
-			else break;
-		}
-		else {
-escape:
-			if(outc + 3 <= MAX_LINELEN) {
-				*out++ = '=';
-				outc++;
-				get_hex_str(out, *in);
-				out += 2;
-				outc += 2;
-				in++;
-				inc++;
+	while (*inp != '\0') {
+		ch = *inp;
+
+		if (IS_LBREAK(inp)) {
+			*outp++ = '\n';
+			len = 0;
+			if (*inp == '\r')
+				inp++;
+			inp++;
+		} else if (ch == '\t' || ch == ' ') {
+			if (IS_LBREAK(inp + 1)) {
+				SOFT_LBREAK_IF_REQUIRED(3);
+				*outp++ = '=';
+				get_hex_str(outp, ch);
+				outp += 2;
+				len += 3;
+				inp++;
+			} else {
+				SOFT_LBREAK_IF_REQUIRED(1);
+				*outp++ = *inp++;
+				len++;
 			}
-			else break;
+		} else if ((ch >= 33 && ch <= 60) || (ch >= 62 && ch <= 126)) {
+			SOFT_LBREAK_IF_REQUIRED(1);
+			*outp++ = *inp++;
+			len++;
+		} else {
+			SOFT_LBREAK_IF_REQUIRED(3);
+			*outp++ = '=';
+			get_hex_str(outp, ch);
+			outp += 2;
+			len += 3;
+			inp++;
 		}
 	}
-	g_assert(outc <= MAX_LINELEN);
-	*out++ = '=';
-	*out = '\0';
-	return inc;
-}
 
-void qp_encode_line(gchar *out, const guchar *in) {
-	while (*in != '\0') {
-		in += qp_encode(TRUE, out, in, strlen(in));
+	if (len > 0)
+		*outp++ = '\n';
 
-		while(*out != '\0') out++;
-		*out++ = '\n';
-		*out++ = '\0';
-	}
+	*outp = '\0';
 }
 
 gint qp_decode_line(gchar *str)

Index: quoted-printable.h
===================================================================
RCS file: /home/claws-mail/claws/src/common/quoted-printable.h,v
retrieving revision 1.3.2.10
retrieving revision 1.3.2.11
diff -u -d -r1.3.2.10 -r1.3.2.11
--- quoted-printable.h	3 Jul 2012 17:23:00 -0000	1.3.2.10
+++ quoted-printable.h	10 Jul 2012 21:13:07 -0000	1.3.2.11
@@ -22,18 +22,6 @@
 
 #include <glib.h>
 
-/* Processes at most 78 characters from in buffer,
- * and stores one NULL-terminated line of at most 76 characters (excl. \0) of
- * quoted-printable output without terminating newline characters in out buffer.
- * Except when encoding text, every output line ends in a soft line break.
- * Therefore the caller can chain multiple lines of encoded data resulting from
- * sequential runs by glueing them together with line breaks.
- * The number of processed input characters is returned. */
-gint qp_encode			(gboolean	text,
-				 gchar		*out,
-				 const guchar	*in,
-				 gint		len);
-/* Deprecated */
 void qp_encode_line		(gchar		*out,
 				 const guchar	*in);
 gint qp_decode_line		(gchar		*str);



More information about the Commits mailing list