diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-07-23 13:42:23 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-07-23 14:07:58 +0300 |
commit | ff9c0a396c14c219532dd667d49ebc7a3f376f9b (patch) | |
tree | a0d9a259072018dd97b936042df7d89daa3c8b41 /libmailutils/tests | |
parent | 78c28187ffb8f6ae8aa0662e6be193d23ae7808b (diff) | |
download | mailutils-ff9c0a396c14c219532dd667d49ebc7a3f376f9b.tar.gz mailutils-ff9c0a396c14c219532dd667d49ebc7a3f376f9b.tar.bz2 |
Relax sytnax requirements for MIME structured headers.
* libmailutils/base/ctparse.c (content_type_parse): Rewrite
the value splitting on type and subtype. Allow for optional
whitespace at both sides of "/". Both type and subtype can contain
arbitrary characters (except for "/"). This is not right according
to RFC 2045, but reportedly such cases exist in old mails.
* libmailutils/mailbox/bodystruct.c (bodystructure_fill): Fix
parsing of the Content-Type header.
Fix storing the pointer to an automatic variable in assoc object.
Unfold the Content-Disposition value.
* libmailutils/mime/mimehdr.c (_mime_header_parse): Return in pvalue
entire prefix part up to the first semicolon, with leading and
trailing whitespace removed. Allow for both output parameters to
be NULL.
* libmailutils/tests/content-type.at: Add new test case.
* libmailutils/tests/conttype.c: ignore empty lines in input.
* libmailutils/tests/mimehdr.at: Change mimehdr16 and mimehdr17
tests: this syntax is accepted by the relaxed rules of the
modified parser.
Diffstat (limited to 'libmailutils/tests')
-rw-r--r-- | libmailutils/tests/content-type.at | 9 | ||||
-rw-r--r-- | libmailutils/tests/conttype.c | 2 | ||||
-rw-r--r-- | libmailutils/tests/mimehdr.at | 11 |
3 files changed, 16 insertions, 6 deletions
diff --git a/libmailutils/tests/content-type.at b/libmailutils/tests/content-type.at index adeeeadeb..7dbda629f 100644 --- a/libmailutils/tests/content-type.at +++ b/libmailutils/tests/content-type.at @@ -49,5 +49,14 @@ CTHDR([missing subtype],[ctparse content-type], [conttype: Parse error ]) +CTHDR([whitespace],[ctparse content-type], +[ text / plain ; charset = utf-8;p =foo], +[0], +[type = text +subtype = plain + 0: charset=utf-8 + 1: p=foo +]) + m4_popdef([CTHDR]) diff --git a/libmailutils/tests/conttype.c b/libmailutils/tests/conttype.c index 1f3920b13..1cbd695c3 100644 --- a/libmailutils/tests/conttype.c +++ b/libmailutils/tests/conttype.c @@ -53,6 +53,8 @@ main (int argc, char **argv) while ((rc = mu_stream_getline (mu_strin, &buf, &size, &n)) == 0 && n > 0) { mu_rtrim_class (buf, MU_CTYPE_ENDLN); + if (buf[0] == 0) + continue; if (parse (buf)) result = 1; } diff --git a/libmailutils/tests/mimehdr.at b/libmailutils/tests/mimehdr.at index cef3a6e9b..ea6fab5f4 100644 --- a/libmailutils/tests/mimehdr.at +++ b/libmailutils/tests/mimehdr.at @@ -277,18 +277,17 @@ MIMEHDR_FAIL([empty input],[mimehdr15], [mimehdr: mu_mime_header_parse() failed: Parse error ]) -MIMEHDR_FAIL([missing semicolon after type],[mimehdr16], +MIMEHDR([missing semicolon after type],[mimehdr16], [], [message name="foo"], -[], -[mimehdr: mu_mime_header_parse() failed: Parse error +[message name="foo" ]) -MIMEHDR_FAIL([whitespace in type],[mimehdr17], +MIMEHDR([whitespace in type],[mimehdr17], [], [TeX file/plain; name=foo], -[], -[mimehdr: mu_mime_header_parse() failed: Parse error +[TeX file/plain +name=foo ]) m4_popdef([MIMEHDR]) |