From 9a048db1f1340cc6ef06a8dc40e534ca875e6262 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Thu, 25 Feb 1999 06:58:01 +0000 Subject: parse some more from_ lines. Before, there were problems with cases 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 | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'from.c') diff --git a/from.c b/from.c index 27bcd8a8..cd45d51f 100644 --- 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) -- cgit v1.2.3