diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2005-05-01 22:20:40 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2005-05-01 22:20:40 +0000 |
commit | 79c3c60a190ef88a15918c1890be4919becaace9 (patch) | |
tree | 3a83adf262a0a21f5fed1cbd99f12099521c4b8d /content/fetchcache.c | |
parent | 03810e4b6c62164f2d3080bcb5851109dedb1884 (diff) | |
download | netsurf-79c3c60a190ef88a15918c1890be4919becaace9.tar.gz netsurf-79c3c60a190ef88a15918c1890be4919becaace9.tar.bz2 |
[project @ 2005-05-01 22:20:40 by jmb]
Work around invalid Content-Type headers
svn path=/import/netsurf/; revision=1707
Diffstat (limited to 'content/fetchcache.c')
-rw-r--r-- | content/fetchcache.c | 12 |
1 files changed, 11 insertions, 1 deletions
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; |