From 717ac4a0da4497e262d111b2272461cf4d98322c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 21 Jan 1997 20:09:24 +0000 Subject: Improved rewrite. svn path=/trunk/; revision=796 --- rfc822.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/rfc822.c b/rfc822.c index efdbcfd8..43aad408 100644 --- a/rfc822.c +++ b/rfc822.c @@ -43,24 +43,27 @@ const char *host; /* server hostname */ printf("state %d: %s", state, mycopy); printf("%*s^\n", from - mycopy + 10, " "); #endif /* TESTMAIN */ - if (*from == '(') - ++parendepth; - else if (*from == ')') - --parendepth; + if (state != 2) + if (*from == '(') + ++parendepth; + else if (*from == ')') + --parendepth; if (!parendepth && !has_host_part) switch (state) { - case 0: /* before header colon */ + case 0: /* before header colon */ if (*from == ':') state = 1; break; - case 1: /* we've seen the colon, we're looking for addresses */ + case 1: /* we've seen the colon, we're looking for addresses */ if (*from == '<') - state = 2; + state = 3; else if (*from == '@') has_host_part = TRUE; + else if (*from == '"') + state = 2; else if ((*from == ',' || HEADER_END(from)) && !has_host_part) { while (isspace(*from)) @@ -76,7 +79,12 @@ const char *host; /* server hostname */ } break; - case 2: /* we're in a <>-enclosed address */ + case 2: /* we're in a string */ + if (*from == '"') + state = 1; + break; + + case 3: /* we're in a <>-enclosed address */ if (*from == '@') has_host_part = TRUE; else if (*from == '>' && !has_host_part) -- cgit v1.2.3