dovecot-2.2: lib-mail: quoted_printable_decode*() now returns al...

dovecot at dovecot.org dovecot at dovecot.org
Thu Apr 4 19:18:33 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/6821794943a5
changeset: 16164:6821794943a5
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Apr 04 19:18:22 2013 +0300
description:
lib-mail: quoted_printable_decode*() now returns all newlines as CRLF.
This is required by BINARY fetches, since the original data had CRLFs.

diffstat:

 src/lib-mail/quoted-printable.c      |  11 +++--------
 src/lib-mail/quoted-printable.h      |   3 ++-
 src/lib-mail/test-quoted-printable.c |   2 +-
 3 files changed, 6 insertions(+), 10 deletions(-)

diffs (58 lines):

diff -r 088481a77a7a -r 6821794943a5 src/lib-mail/quoted-printable.c
--- a/src/lib-mail/quoted-printable.c	Thu Apr 04 19:03:26 2013 +0300
+++ b/src/lib-mail/quoted-printable.c	Thu Apr 04 19:18:22 2013 +0300
@@ -33,7 +33,7 @@
 {
 	char hexbuf[3];
 	size_t src_pos, pos, next;
-	bool have_cr, errors = FALSE;
+	bool errors = FALSE;
 	int ret;
 
 	hexbuf[2] = '\0';
@@ -46,18 +46,13 @@
 		if (src[src_pos] == '\n') {
 			/* drop trailing whitespace */
 			pos = src_pos;
-			if (pos > 0 && src[pos-1] == '\r') {
+			if (pos > 0 && src[pos-1] == '\r')
 				pos--;
-				have_cr = TRUE;
-			} else {
-				have_cr = FALSE;
-			}
 			while (pos > 0 && QP_IS_TRAILING_SPACE(src[pos-1]))
 				pos--;
 			buffer_append(dest, src + next, pos - next);
 			next = src_pos+1;
-			if (have_cr)
-				buffer_append_c(dest, '\r');
+			buffer_append_c(dest, '\r');
 			buffer_append_c(dest, '\n');
 			continue;
 		}
diff -r 088481a77a7a -r 6821794943a5 src/lib-mail/quoted-printable.h
--- a/src/lib-mail/quoted-printable.h	Thu Apr 04 19:03:26 2013 +0300
+++ b/src/lib-mail/quoted-printable.h	Thu Apr 04 19:18:22 2013 +0300
@@ -3,7 +3,8 @@
 
 /* Translates quoted printable data into binary. dest must be at least the
    size of src, and may be same as src. Returns 0 if input was valid, -1 if
-   there were some decoding errors (which were skipped over).
+   there were some decoding errors (which were skipped over). LFs without
+   preceding CR are returned as CRLF (but =0A isn't).
 
    This function may be called multiple times for parsing the same stream.
    src_pos is updated to first non-translated character in src. */
diff -r 088481a77a7a -r 6821794943a5 src/lib-mail/test-quoted-printable.c
--- a/src/lib-mail/test-quoted-printable.c	Thu Apr 04 19:03:26 2013 +0300
+++ b/src/lib-mail/test-quoted-printable.c	Thu Apr 04 19:18:22 2013 +0300
@@ -21,7 +21,7 @@
 		{ "foo = \n=01", "foo \001", 0, 0 },
 		{ "foo =\t\r\nbar", "foo bar", 0, 0 },
 		{ "foo =\r\n=01", "foo \001", 0, 0 },
-		{ "foo  \nbar=", "foo\nbar", 1, 0 },
+		{ "foo  \nbar=", "foo\r\nbar", 1, 0 },
 		{ "=0A=0D  ", "\n\r", 2, 0 },
 		{ "foo_bar", "foo_bar", 0, 0 },
 		{ "foo=", "foo", 1, 0 },


More information about the dovecot-cvs mailing list