summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-07-29 12:11:56 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-07-29 12:11:56 +0300
commitbae847821ac56157d4e0104a9bb274673cfa059f (patch)
tree61d27864b9c1e5b795422f7b8f628b7712634e22 /lib
parent90cf55bc239b7665280714fbdba1e54e78ddaa3a (diff)
downloadmailutils-bae847821ac56157d4e0104a9bb274673cfa059f.tar.gz
mailutils-bae847821ac56157d4e0104a9bb274673cfa059f.tar.bz2
Relax syntax rules for parsing Content-Type headers.
* decodemail/decodemail.c (qstring_format): Account for s==NULL (message_decode): Use MU_CONTENT_TYPE_RELAXED when parsing content types. * doc/texinfo/programs/decodemail.texi: Document handling of partial content types. * include/mailutils/util.h (MU_CONTENT_TYPE_STRICT) (MU_CONTENT_TYPE_RELAXED) (MU_CONTENT_TYPE_PARAM): New constants. (mu_content_type_parse_ext): New function. * lib/mdecode.c (text_mime_cmp): Implement comparison of partial content types (missing subtype). (message_body_stream): Use MU_CONTENT_TYPE_RELAXED. * libmailutils/base/ctparse.c (content_type_parse): Take additional argument (flags). Modify parsing algorithm depending on its value. (mu_content_type_parse_ext): New function. (mu_content_type_parse): Rewrite as a wrapper over mu_content_type_parse_ext. (mu_content_type_destroy): Account for subtype==NULL.
Diffstat (limited to 'lib')
-rw-r--r--lib/mdecode.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/mdecode.c b/lib/mdecode.c
index 355bb45b7..9f0c4a9e5 100644
--- a/lib/mdecode.c
+++ b/lib/mdecode.c
@@ -48,10 +48,14 @@ text_mime_cmp (const void *item, const void *ptr)
{
const struct mime_pattern *pat = item;
mu_content_type_t ct = (mu_content_type_t) ptr;
- if (mu_imap_wildmatch_ci (pat->pat_type, ct->type, 0) == 0
- && (pat->pat_subtype == NULL
- || mu_imap_wildmatch (pat->pat_subtype, ct->subtype, '/') == 0))
- return 0;
+ if (mu_imap_wildmatch_ci (pat->pat_type, ct->type, 0) == 0)
+ {
+ if (ct->subtype == NULL)
+ return pat->pat_subtype != NULL;
+ if (pat->pat_subtype == NULL
+ || mu_imap_wildmatch (pat->pat_subtype, ct->subtype, '/') == 0)
+ return 0;
+ }
return 1;
}
@@ -211,7 +215,7 @@ message_body_stream (mu_message_t msg, int unix_header, char const *charset,
return rc;
}
- rc = mu_content_type_parse (buf, NULL, &ct);
+ rc = mu_content_type_parse_ext (buf, NULL, MU_CONTENT_TYPE_RELAXED, &ct);
if (rc)
{
mu_diag_funcall (MU_DIAG_ERROR, "mu_content_type_parse", buf, rc);

Return to:

Send suggestions and report system problems to the System administrator.