Index: address.c =================================================================== RCS file: /cvs/mailutils/mailbox/address.c,v retrieving revision 1.13 diff -u -r1.13 address.c --- address.c 2001/05/20 04:34:35 1.13 +++ address.c 2001/05/27 00:24:00 @@ -38,55 +38,12 @@ /* 'paddress' must exist, and can't already have been initialized */ int status; - const char *e; - const char *save; - char *fb; if (!a) return EINVAL; *a = NULL; - save = s; - e = &s[strlen (s)]; - fb = calloc (1, 1); - if (!fb) - return ENOMEM; - - /* We need to unfold the string. Do the same thing as parse822_field_body() - but we have to be more flexible in allowing bare '\n' as CRLF for - unix-mbox. This is may not be the right approach still. */ - for (;;) - { - const char *eol = s; - size_t len = strlen (fb); - while (eol != e) - { - /* if (eol[0] == '\r' && (eol+1) != e && eol[1] == '\n') */ - if (*eol == '\n') - break; - ++eol; - } - - fb = realloc (fb, len + (eol - s) + 1); - memcpy (fb + len , s, eol - s); - fb[len + (eol - s)] = '\0'; - - s = eol; - if (eol == e) - break; /* no more, so we're done */ - - s++; - - if (s == e) - break; /* no more, so we're done */ - - /* check if next line is a continuation line */ - if (*s != ' ' && *s != '\t') - break; - } - - status = parse822_address_list (a, (char*) fb); - free (fb); + status = parse822_address_list (a, (char*) s); if (status == 0) { /* And address-list may contain 0 addresses but parse correctly. @@ -94,7 +51,7 @@ if (!*a) return ENOENT; - (*a)->addr = strdup (save); + (*a)->addr = strdup (s); if (!(*a)->addr) { address_destroy (a); Index: parse822.c =================================================================== RCS file: /cvs/mailutils/mailbox/parse822.c,v retrieving revision 1.9 diff -u -r1.9 parse822.c --- parse822.c 2001/05/20 02:37:16 1.9 +++ parse822.c 2001/05/27 00:24:02 @@ -211,9 +211,13 @@ /***** From RFC 822, 3.3 Lexical Tokens *****/ -int parse822_skip_crlf(const char** p, const char* e) +int parse822_skip_nl(const char** p, const char* e) { + /* Here we consider a new-line (NL) to be either a bare LF, or + * a CRLF pair as required by the RFC. + */ const char* s = *p; + if( (&s[1] < e) && s[0] == '\r' && @@ -224,6 +228,17 @@ return EOK; } + + if( + (&s[0] < e) && + s[0] == '\n' + ) + { + *p += 1; + + return EOK; + } + return EPARSE; } int parse822_skip_lwsp_char(const char** p, const char* e) @@ -237,7 +252,12 @@ int parse822_skip_lwsp(const char** p, const char* e) { /* - * linear-white-space = 1*([CRLF] LWSP-char) + * linear-white-space = 1*([[CR]LF] LWSP-char) + * + * We interpret a bare LF as identical to the canonical CRLF + * line ending, I don't know another way since on a Unix system + * all CRLF will be translated to the local convention, a bare + * LF, and thus we can not deal with bare NLs in the message. */ int space = 0; @@ -248,7 +268,7 @@ space = 1; continue; } - if(parse822_skip_crlf(p, e) == EOK) { + if(parse822_skip_nl(p, e) == EOK) { if(parse822_skip_lwsp_char(p, e) == EOK) { continue; }