From: Phil Carmody Date: Mon, 28 Jul 2014 13:49:47 +0000 (+0300) Subject: lib-imap: imap-utf7 - only encode in-range 7-bit values X-Git-Tag: 2.2.14.rc1~208 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4de99500799c3518fa697cbc249bea4b266153ad;p=thirdparty%2Fdovecot%2Fcore.git lib-imap: imap-utf7 - only encode in-range 7-bit values 0x01-0x1F and 0x7f-... must be mBASE64 encoded. Signed-off-by: Phil Carmody --- diff --git a/src/lib-imap/imap-utf7.c b/src/lib-imap/imap-utf7.c index 98ec93cc8b..8126453203 100644 --- a/src/lib-imap/imap-utf7.c +++ b/src/lib-imap/imap-utf7.c @@ -60,7 +60,7 @@ static const char *imap_utf8_first_encode_char(const char *str) const char *p; for (p = str; *p != '\0'; p++) { - if (*p == '&' || (unsigned char)*p >= 0x80) + if (*p == '&' || *p < 0x20 || *p >= 0x7f) return p; } return NULL; @@ -89,14 +89,14 @@ int imap_utf8_to_utf7(const char *src, string_t *dest) p++; continue; } - if ((unsigned char)*p < 0x80) { + if (*p >= 0x20 && *p < 0x7f) { str_append_c(dest, *p); p++; continue; } u = utf16; - while ((unsigned char)*p >= 0x80) { + while (*p != '\0' && (*p < 0x20 || *p >= 0x7f)) { if (uni_utf8_get_char(p, &chr) <= 0) return -1; /* @UNSAFE */