From 79c3c60a190ef88a15918c1890be4919becaace9 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 1 May 2005 22:20:40 +0000 Subject: [project @ 2005-05-01 22:20:40 by jmb] Work around invalid Content-Type headers svn path=/import/netsurf/; revision=1707 --- content/fetchcache.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/content/fetchcache.c b/content/fetchcache.c index 617a4ead5..e188fea54 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -384,7 +384,17 @@ char *fetchcache_parse_type(const char *s, char **params[]) r = regexec(&re_content_type, s, 2 + MAX_ATTRS * 3, pmatch, 0); if (r) { LOG(("failed to parse content-type '%s'", s)); - type = strdup(s); + /* The mime type must be first, so only copy up to the + * first semicolon in the string. This allows us to have + * a better attempt at handling pages sent with broken + * Content-Type headers. Obviously, any truly broken + * Content-Type headers will be unaffected by this heuristic + */ + char *semi = strchr(s, ';'); + if (semi) + type = strndup(s, semi - s); + else + type = strdup(s); if (!type) goto no_memory; return type; -- cgit v1.2.3