diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/html.cc | 37 | ||||
-rw-r--r-- | src/html_common.hh | 1 | ||||
-rw-r--r-- | src/styleengine.hh | 1 |
3 files changed, 20 insertions, 19 deletions
diff --git a/src/html.cc b/src/html.cc index dc9fc617..1f375da3 100644 --- a/src/html.cc +++ b/src/html.cc @@ -456,7 +456,6 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url, InVisitedLink = false; ReqTagClose = false; TagSoup = true; - NameVal = NULL; Num_HTML = Num_HEAD = Num_BODY = Num_TITLE = 0; @@ -2383,11 +2382,24 @@ static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize) html->styleEngine->inheritBackgroundColor (); if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "name"))) { + char *nameVal; + const char *id = html->styleEngine->getId (); + if (prefs.show_extra_warnings) Html_check_name_val(html, attrbuf, "name"); - /* html->NameVal is freed in Html_process_tag */ - html->NameVal = a_Url_decode_hex_str(attrbuf); - Html_add_anchor(html, html->NameVal); + + nameVal = a_Url_decode_hex_str(attrbuf); + + if (nameVal) { + /* We compare the "id" value with the url-decoded "name" value */ + if (!id || strcmp(nameVal, id)) { + if (id) + BUG_MSG("'id' and 'name' attribute of <a> tag differ\n"); + Html_add_anchor(html, nameVal); + } + + dFree(nameVal); + } } } @@ -3312,21 +3324,10 @@ static void Html_parse_common_attrs(DilloHtml *html, char *tag, int tagsize) * spec states in Sec. 7.5.2 that anchor ids are case-sensitive. * So we don't do it and hope for better specs in the future ... */ - if (attrbuf) - html->styleEngine->setId (attrbuf); - Html_check_name_val(html, attrbuf, "id"); - /* We compare the "id" value with the url-decoded "name" value */ - if (!html->NameVal || strcmp(html->NameVal, attrbuf)) { - if (html->NameVal) - BUG_MSG("'id' and 'name' attribute of <a> tag differ\n"); - Html_add_anchor(html, attrbuf); - } - } - /* Reset NameVal */ - if (html->NameVal) { - dFree(html->NameVal); - html->NameVal = NULL; + + html->styleEngine->setId(attrbuf); + Html_add_anchor(html, attrbuf); } if (tagsize >= 10) { /* length of "<t class=i>" */ diff --git a/src/html_common.hh b/src/html_common.hh index 7983ea5a..fc0800f7 100644 --- a/src/html_common.hh +++ b/src/html_common.hh @@ -198,7 +198,6 @@ public: //BUG: for now everything is public 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 */ - char *NameVal; /* used for validation of "NAME" and "ID" in <A> */ /* element counters: used for validation purposes */ uchar_t Num_HTML, Num_HEAD, Num_BODY, Num_TITLE; diff --git a/src/styleengine.hh b/src/styleengine.hh index 75f8fdd1..a17a350c 100644 --- a/src/styleengine.hh +++ b/src/styleengine.hh @@ -48,6 +48,7 @@ class StyleEngine : public Doctree { void parse (const char *buf, int buflen, CssOrigin origin); void startElement (int tag); void setId (const char *id); + const char * getId () { return top ()->id; }; void setClass (const char *klass); void setStyle (const char *style); void endElement (int tag); |