From 1cfc5b89706e1975244cfe2362ad6c429a7daa9a Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 14 Mar 2011 18:53:13 +0000 Subject: More rigourous MIME type checking for CSS allows us to remove the icons from included CSS files. svn path=/trunk/netsurf/; revision=12049 --- amiga/filetype.c | 38 ++++++++++++++++++++++++----------- amiga/gui.c | 17 ++++++++++------ amiga/resources/AdBlock.css.info | Bin 8394 -> 0 bytes amiga/resources/Themes/Default/Theme | 3 +++ amiga/resources/amiga.css.info | Bin 8394 -> 0 bytes amiga/resources/default.css.info | Bin 8394 -> 0 bytes amiga/resources/internal.css.info | Bin 8394 -> 0 bytes amiga/resources/quirks.css.info | Bin 8394 -> 0 bytes 8 files changed, 40 insertions(+), 18 deletions(-) delete mode 100644 amiga/resources/AdBlock.css.info delete mode 100644 amiga/resources/amiga.css.info delete mode 100644 amiga/resources/default.css.info delete mode 100644 amiga/resources/internal.css.info delete mode 100644 amiga/resources/quirks.css.info (limited to 'amiga') 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 + * Copyright 2008, 2011 Chris Young * * 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; } diff --git a/amiga/gui.c b/amiga/gui.c index 5f638ebba..d8599e6b7 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -452,14 +452,19 @@ char* gui_find_resource(const char *filename) if(ami_locate_resource(path, filename) == false) { - /* Try with RISC OS HTML filetype, might work */ - strcpy(filename2, filename); - strcat(filename2, ",faf"); - - if(ami_locate_resource(path, filename2) == false) + if((strncmp(filename + strlen(filename) - 4, ".htm", 4) == 0) || + (strncmp(filename + strlen(filename) - 5, ".html", 5) == 0)) { - return NULL; + /* Try with RISC OS HTML filetype, might work */ + strcpy(filename2, filename); + strcat(filename2, ",faf"); + + if(ami_locate_resource(path, filename2) == false) + { + return NULL; + } } + else return NULL; } return path_to_url(path); diff --git a/amiga/resources/AdBlock.css.info b/amiga/resources/AdBlock.css.info deleted file mode 100644 index 00d089d7b..000000000 Binary files a/amiga/resources/AdBlock.css.info and /dev/null differ diff --git a/amiga/resources/Themes/Default/Theme b/amiga/resources/Themes/Default/Theme index 28b38e006..cf7ec8f37 100755 --- a/amiga/resources/Themes/Default/Theme +++ b/amiga/resources/Themes/Default/Theme @@ -16,6 +16,9 @@ # theme_throbber is a film strip of theme_throbber_frames frames # The first frame must be the inactive image. # +# Various default CSS styles can be overridden by adding a file +# "amiga.css" in this directory. +# theme_nav_west:back.png theme_nav_west_s:back_h.png theme_nav_west_g:back_g.png diff --git a/amiga/resources/amiga.css.info b/amiga/resources/amiga.css.info deleted file mode 100644 index 9bc777ede..000000000 Binary files a/amiga/resources/amiga.css.info and /dev/null differ diff --git a/amiga/resources/default.css.info b/amiga/resources/default.css.info deleted file mode 100644 index 9b94dd146..000000000 Binary files a/amiga/resources/default.css.info and /dev/null differ diff --git a/amiga/resources/internal.css.info b/amiga/resources/internal.css.info deleted file mode 100644 index 3593cfcca..000000000 Binary files a/amiga/resources/internal.css.info and /dev/null differ diff --git a/amiga/resources/quirks.css.info b/amiga/resources/quirks.css.info deleted file mode 100644 index 9b94dd146..000000000 Binary files a/amiga/resources/quirks.css.info and /dev/null differ -- cgit v1.2.3