summaryrefslogtreecommitdiffstats
path: root/from.c
diff options
context:
space:
mode:
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)