From a5ba499763d921181cd24c2c6aaacf78883a17f1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 21 Sep 2017 09:17:06 +0200 Subject: imap: quote atoms properly when escaping characters Updates test 800 to verify Fixes #1902 --- lib/imap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/imap.c') diff --git a/lib/imap.c b/lib/imap.c index d37113aae..954d18f37 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -1797,7 +1797,7 @@ static char *imap_atom(const char *str, bool escape_only) return strdup(str); /* Calculate the new string length */ - newlen = strlen(str) + backsp_count + quote_count + (others_exists ? 2 : 0); + newlen = strlen(str) + backsp_count + quote_count + (escape_only ? 0 : 2); /* Allocate the new string */ newstr = (char *) malloc((newlen + 1) * sizeof(char)); @@ -1806,7 +1806,7 @@ static char *imap_atom(const char *str, bool escape_only) /* Surround the string in quotes if necessary */ p2 = newstr; - if(others_exists) { + if(!escape_only) { newstr[0] = '"'; newstr[newlen - 1] = '"'; p2++; -- cgit v1.2.1