summaryrefslogtreecommitdiffstats
path: root/from.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1999-02-25 06:58:01 +0000
committerThomas Roessler <roessler@does-not-exist.org>1999-02-25 06:58:01 +0000
commit9a048db1f1340cc6ef06a8dc40e534ca875e6262 (patch)
tree9b8db603ee073a53ce5d39578db56ca3a3fba1a3 /from.c
parentadaf4346cfc89b3b8feea8bc50b0177c7a805a2e (diff)
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
Diffstat (limited to 'from.c')
-rw-r--r--from.c33
1 files changed, 13 insertions, 20 deletions
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)