changeset 1013:f4d5923de127

load <style></style> content only if applicable
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Thu, 19 Mar 2009 21:38:54 +0100
parents 306ce2f3228f
children c5037d64452b
files ChangeLog src/html.cc src/html_common.hh
diffstat 3 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Mar 18 06:08:48 2009 +0000
+++ b/ChangeLog	Thu Mar 19 21:38:54 2009 +0100
@@ -74,6 +74,7 @@
  - Replace visited_color dillorc option.
  - Add support for negative numbers in CSS parser.
  - Fix allow_white_bg dillorc option.
+ - Load <style></style> content only if applicable.
    Patches: Johannes Hofmann
 +- Updated the GPL copyright note in the source files.
    Patch: Detlef Riekenberg
--- a/src/html.cc	Wed Mar 18 06:08:48 2009 +0000
+++ b/src/html.cc	Thu Mar 19 21:38:54 2009 +0100
@@ -457,6 +457,7 @@
    InVisitedLink = false;
    ReqTagClose = false;
    TagSoup = true;
+   loadCssFromStash = false;
 
    Num_HTML = Num_HEAD = Num_BODY = Num_TITLE = 0;
 
@@ -1642,11 +1643,12 @@
 {
    const char *attrbuf;
 
+   html->loadCssFromStash = true;
+
    if (!(attrbuf = a_Html_get_attr(html, tag, tagsize, "type"))) {
       BUG_MSG("type attribute is required for <style>\n");
    } else if (dStrcasecmp(attrbuf, "text/css")) {
-      MSG("Shouldn't be applying <style type=\"%s\">\n", attrbuf);
-      /* We need to inform close_style() */
+      html->loadCssFromStash = false;
    }
    if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "media")) &&
        dStrcasecmp(attrbuf, "all") && !dStristr(attrbuf, "screen")) {
@@ -1655,8 +1657,9 @@
        * TODO can be a comma-separated list.
        * TODO handheld.
        */
-      MSG("Shouldn't be applying <style media=\"%s\">\n", attrbuf);
+      html->loadCssFromStash = false;
    }
+
    a_Html_stash_init(html);
    S_TOP(html)->parse_mode = DILLO_HTML_PARSE_MODE_VERBATIM;
 }
@@ -1666,7 +1669,7 @@
  */
 static void Html_tag_close_style(DilloHtml *html, int TagIdx)
 {
-   if (prefs.parse_embedded_css)
+   if (prefs.parse_embedded_css && html->loadCssFromStash)
       html->styleEngine->parse(html->Stash->str, html->Stash->len,
                                CSS_ORIGIN_AUTHOR);
 }
--- a/src/html_common.hh	Wed Mar 18 06:08:48 2009 +0000
+++ b/src/html_common.hh	Thu Mar 19 21:38:54 2009 +0100
@@ -178,6 +178,7 @@
    bool ReqTagClose;      /* Flag to help handling bad-formed HTML */
    bool WordAfterLI;      /* Flag to help ignoring the 1st <P> after <LI> */
    bool TagSoup;          /* Flag to enable the parser's cleanup functions */
+   bool loadCssFromStash; /* current stash content should be loaded as CSS */
 
    /* element counters: used for validation purposes */
    uchar_t Num_HTML, Num_HEAD, Num_BODY, Num_TITLE;