]> granicus.if.org Git - curl/commitdiff
imap: quote atoms properly when escaping characters
authorDaniel Stenberg <daniel@haxx.se>
Thu, 21 Sep 2017 07:17:06 +0000 (09:17 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 22 Sep 2017 12:43:37 +0000 (14:43 +0200)
Updates test 800 to verify

Fixes #1902
Closes #1903

lib/imap.c
tests/data/test800

index d37113aaebf8f7f3a4a6b9aab3815f37546bc64f..954d18f378643a406e33382d26839de2ff9d8769 100644 (file)
@@ -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++;
index 1ac1da59bb72ab7016b071ada4f062b9ac35581b..360206b43d7947b65fd74e1d01d3884a9da235fe 100644 (file)
@@ -31,7 +31,7 @@ imap
 IMAP FETCH message
  </name>
  <command>
-'imap://%HOSTIP:%IMAPPORT/800/;UID=1' -u "user*:secret{"
+'imap://%HOSTIP:%IMAPPORT/800/;UID=1' -u '"user:sec"ret{'
 </command>
 </client>
 
@@ -40,7 +40,7 @@ IMAP FETCH message
 <verify>
 <protocol>
 A001 CAPABILITY\r
-A002 LOGIN "user*" "secret{"\r
+A002 LOGIN "\"user" "sec\"ret{"\r
 A003 SELECT 800\r
 A004 FETCH 1 BODY[]\r
 A005 LOGOUT\r