From 7d64feadc43b9051bc7d5f8c638d52539f91c7f6 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 13 Jan 1997 21:44:38 +0000 Subject: Fix Steven Trainoff's bug. svn path=/trunk/; revision=755 --- rfc822.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/rfc822.c b/rfc822.c index 31bf0c67..8820b1b5 100644 --- a/rfc822.c +++ b/rfc822.c @@ -233,29 +233,34 @@ const char *hdr; /* header to be parsed, NUL to continue previous hdr */ case BARE_ADDRESS: /* collecting address without delimiters */ if (*hp == '\n') /* end of bare address */ { - *tp++ = '\0'; - state = ENDIT_ALL; - return(tp = address); + if (tp > address) + { + *tp++ = '\0'; + state = ENDIT_ALL; + return(tp = address); + } } else if (*hp == '\\') /* handle RFC822 escaping */ { *tp++ = *hp++; /* take the escape */ *tp++ = *hp; /* take following char */ } - else if (*hp == ',' || isspace(*hp)) /* end of address */ + else if (*hp == ',') /* end of address */ { if (tp > address) { *tp++ = '\0'; - ++hp; state = SKIP_JUNK; return(tp = address); } } - else /* just take it */ + else if (*hp == '<') /* beginning of real address */ { - *tp++ = *hp; + state = INSIDE_BRACKETS; + tp = address; } + else /* just take it */ + *tp++ = *hp; break; case INSIDE_DQUOTE: /* we're in a quoted string, copy verbatim */ -- cgit v1.2.3