Commits

Anonymous committed fec2720

Fix #2014.
Thanks to Vincent Lefevre for help with this one.

Comments (0)

Files changed (2)

-2010-03-01 16:14 -0800  Brendan Cully  <brendan@kublai.com>  (86d93280e5b3)
+2010-03-02 11:16 -0800  Brendan Cully  <brendan@kublai.com>  (41cf44ddbb4c)
+
+	* copy.c: Fix thinko in [cc02f079b1b9]
+
+2010-03-01 22:40 -0800  Brendan Cully  <brendan@kublai.com>  (cc02f079b1b9)
+
+	* copy.c: Guard dequote with NULL check on personal field
+
+	* copy.c, rfc822.c, rfc822.h: Another attempt to dequote
+	RFC2047-encoded address comments (see #2014)
 
 	* rfc822.c: Backed out changeset 2a4ca6917fd0. It is incompatible with
 	$assumed_charset (see #2014).
 static const char *
 parse_quote (const char *s, char *token, size_t *tokenlen, size_t tokenmax)
 {
-  if (*tokenlen < tokenmax)
-    token[(*tokenlen)++] = '"';
   while (*s)
   {
     if (*tokenlen < tokenmax)
       token[*tokenlen] = *s;
-    if (*s == '"')
-    {
-      (*tokenlen)++;
-      return (s + 1);
-    }
     if (*s == '\\')
     {
       if (!*++s)
       if (*tokenlen < tokenmax)
 	token[*tokenlen] = *s;
     }
+    else if (*s == '"')
+      return (s + 1);
     (*tokenlen)++;
     s++;
   }
       }
       s = ps;
     }
+    else if (*s == '"')
+    {
+      if (phraselen && phraselen < sizeof (phrase) - 1)
+        phrase[phraselen++] = ' ';
+      if ((ps = parse_quote (s + 1, phrase, &phraselen, sizeof (phrase) - 1)) == NULL)
+      {
+        rfc822_free_address (&top);
+        return NULL;
+      }
+      s = ps;
+    }
     else if (*s == ':')
     {
       cur = rfc822_new_address ();
       terminate_buffer (phrase, phraselen);
       cur = rfc822_new_address ();
       if (phraselen)
-      {
-	/* if we get something like "Michael R. Elkins" remove the quotes */
-	rfc822_dequote_comment (phrase);
 	cur->personal = safe_strdup (phrase);
-      }
       if ((ps = parse_route_addr (s + 1, comment, &commentlen, sizeof (comment) - 1, cur)) == NULL)
       {
 	rfc822_free_address (&top);