dovecot-2.2: quoted-printable decoding: Don't add CR if it wasn'...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Mar 18 15:47:25 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/689dbeadf168
changeset: 16030:689dbeadf168
user: Timo Sirainen <tss at iki.fi>
date: Mon Mar 18 15:46:16 2013 +0200
description:
quoted-printable decoding: Don't add CR if it wasn't in input.
This guarantees that the decoded Q-P won't be larger than its input.
diffstat:
src/lib-mail/quoted-printable.c | 12 +++++++++---
src/lib-mail/test-quoted-printable.c | 2 +-
2 files changed, 10 insertions(+), 4 deletions(-)
diffs (46 lines):
diff -r 69c26a9e3be5 -r 689dbeadf168 src/lib-mail/quoted-printable.c
--- a/src/lib-mail/quoted-printable.c Fri Mar 15 21:58:51 2013 +0100
+++ b/src/lib-mail/quoted-printable.c Mon Mar 18 15:46:16 2013 +0200
@@ -33,7 +33,7 @@
{
char hexbuf[3];
size_t src_pos, pos, next;
- bool errors = FALSE;
+ bool have_cr, errors = FALSE;
int ret;
hexbuf[2] = '\0';
@@ -46,13 +46,19 @@
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;
- buffer_append(dest, "\r\n", 2);
+ if (have_cr)
+ buffer_append_c(dest, '\r');
+ buffer_append_c(dest, '\n');
continue;
}
diff -r 69c26a9e3be5 -r 689dbeadf168 src/lib-mail/test-quoted-printable.c
--- a/src/lib-mail/test-quoted-printable.c Fri Mar 15 21:58:51 2013 +0100
+++ b/src/lib-mail/test-quoted-printable.c Mon Mar 18 15:46:16 2013 +0200
@@ -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\r\nbar", 1, 0 },
+ { "foo \nbar=", "foo\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