diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2011-03-14 18:53:13 +0000 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2011-03-14 18:53:13 +0000 |
commit | 1cfc5b89706e1975244cfe2362ad6c429a7daa9a (patch) | |
tree | 9228770e3c0b8c298818205f2312ca7c3af7416f /amiga/filetype.c | |
parent | 7acc13d8630cd55f74b23e41c07bfdac109c4fbf (diff) | |
download | netsurf-1cfc5b89706e1975244cfe2362ad6c429a7daa9a.tar.gz netsurf-1cfc5b89706e1975244cfe2362ad6c429a7daa9a.tar.bz2 |
More rigourous MIME type checking for CSS allows us to remove the icons from included
CSS files.
svn path=/trunk/netsurf/; revision=12049
Diffstat (limited to 'amiga/filetype.c')
-rw-r--r-- | amiga/filetype.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/amiga/filetype.c b/amiga/filetype.c index 330137bb9..61fe4a5c9 100644 --- a/amiga/filetype.c +++ b/amiga/filetype.c @@ -1,5 +1,5 @@ /* - * Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2008, 2011 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -51,16 +51,6 @@ const char *fetch_filetype(const char *unix_path) found = TRUE; } - /* Have a quick check for the RISC OS CSS filetype. Some of the redirects - * caused by links in the SVN tree prevent NetSurf from reading the MIME - * type from the icon (step two, below). - */ - - if(strncmp(unix_path + strlen(unix_path) - 4, ",f79", 4) == 0) - { - strcpy(mimetype,"text/css"); - found = TRUE; - } /* Secondly try getting a tooltype "MIMETYPE" and use that as the MIME type. Will fail over to default icons if the file doesn't have a real icon. */ @@ -99,7 +89,31 @@ const char *fetch_filetype(const char *unix_path) } } - if(!found) strcpy(mimetype,"text/html"); /* If all else fails */ + /* Have a quick check for file extensions (inc RISC OS filetype). + * Makes detection a little more robust, and some of the redirects + * caused by links in the SVN tree prevent NetSurf from reading the + * MIME type from the icon (step two, above). + */ + + if((!found) || (strcmp("text/plain", mimetype) == 0)) + { + if((strncmp(unix_path + strlen(unix_path) - 4, ".css", 4) == 0) || + (strncmp(unix_path + strlen(unix_path) - 4, ",f79", 4) == 0)) + { + strcpy(mimetype,"text/css"); + found = TRUE; + } + + if((strncmp(unix_path + strlen(unix_path) - 4, ".htm", 4) == 0) || + (strncmp(unix_path + strlen(unix_path) - 5, ".html", 5) == 0) || + (strncmp(unix_path + strlen(unix_path) - 4, ",faf", 4) == 0)) + { + strcpy(mimetype,"text/html"); + found = TRUE; + } + } + + if(!found) strcpy(mimetype,"text/plain"); /* If all else fails */ return mimetype; } |