]> granicus.if.org Git - mutt/commitdiff
parse some more from_ lines. Before, there were problems with cases
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 25 Feb 1999 06:58:01 +0000 (06:58 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 25 Feb 1999 06:58:01 +0000 (06:58 +0000)
like this:

>From <@x400host:"/G=Bob/S=Allinson/CN=Has embedded spaces/OU=X400HOST/
>OU=xxxx/O=xxx/PRMD=xxxxx/ADMD=XXXXXX/C=GB/"@x400host>
>Tue Feb 23 09:44:52 1999

Problem noted by johnm@sirius3.demon.co.uk

from.c

diff --git a/from.c b/from.c
index 27bcd8a8569c7f89b9fbb6d738605ddda019476a..cd45d51fcf1e7746af0752a715d9197c01852064 100644 (file)
--- a/from.c
+++ b/from.c
@@ -78,31 +78,23 @@ time_t is_from (const char *s, char *path, size_t pathlen)
   {
     const char *p;
     size_t len;
+    short q = 0;
 
-    /* looks like we got the return-path, so extract it  */
-    if (*s == '"')
+    for (p = s; *p && (q || !ISSPACE (*p)); p++)
     {
-      /* sometimes we see bogus addresses like
-       *       From "/foo/bar baz/"@dumbdar.com Sat Nov 22 15:29:32 PST 1997
-       */
-      p = s;
-      p++; /* skip over the quote */
-      do
+      if (*p == '\\')
       {
-       if (!(p = strpbrk (p, "\\\"")))
+       if (*++p == '\0') 
          return 0;
-       if (*p == '\\')
-         p += 2;
       }
-      while (*p != '"');
-      while (*p && !ISSPACE (*p))
-       p++;
-    }
-    else
-    {
-      if ((p = strchr (s, ' ')) == NULL)
-       return 0;
+      else if (*p == '"')
+      {
+       q = !q;
+      }
     }
+    
+    if (q || !*p) return 0;
+    
     if (path)
     {
       len = (size_t) (p - s);
@@ -110,8 +102,9 @@ time_t is_from (const char *s, char *path, size_t pathlen)
        len = pathlen - 1;
       memcpy (path, s, len);
       path[len] = 0;
+      dprint (3, (debugfile, "is_from(): got return path: %s\n", path));
     }
-
+    
     s = p + 1;
     SKIPWS (s);
     if (!*s)