From 5e1a3ffecfb86e42d37a62a28d936554577ed1dd Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 23 Sep 1996 15:55:06 +0000 Subject: Handle RFC822 continuation. svn path=/trunk/; revision=108 --- driver.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'driver.c') diff --git a/driver.c b/driver.c index e2a2ad73..24fcae9c 100644 --- a/driver.c +++ b/driver.c @@ -417,8 +417,9 @@ const char *host; /********************************************************************* function: nxtaddr description: Parse addresses in succession out of a specified RFC822 - header. Note: RFC822 escaping with \ is *not* handled. - + header. Note 1: RFC822 escaping with \ is *not* handled. + Note 2: it is important that this routine not stop on \r, + since we use \r as a marker for RFC822 continuations below. arguments: hdr header line to be parsed, NUL to continue in previous hdr @@ -615,8 +616,18 @@ int rewrite; } else { - int newlen = oldlen + strlen(bufp); + int newlen; + /* + * We deal with RFC822 continuation lines here. + * Replace previous '\n' with '\r' so nxtaddr + * and reply-hack will be able to see past it. + * We'll undo this before writing the header. + */ + if (isspace(bufp[0])) + headers[oldlen-1] = '\r'; + + newlen = oldlen + strlen(bufp); headers = realloc(headers, newlen + 1); if (headers == NULL) return(PS_IOERR); @@ -709,6 +720,11 @@ int rewrite; break; } + /* change continuation markers back to regular newlines */ + for (cp = headers; cp < headers + oldlen; cp++) + if (*cp == '\r') + *cp = '\n'; + if (write(mboxfd,headers,oldlen) < 0) { free(headers); -- cgit v1.2.3