Mercurial > dillo_port1.3
changeset 901:f44e88b06200
fix check for name/id mismatch (noticed by corvid)
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> |
---|---|
date | Fri, 06 Feb 2009 12:36:31 +0100 |
parents | eea03bbedb41 |
children | d374a34c891f 4d76ce512830 |
files | src/html.cc src/html_common.hh src/styleengine.hh |
diffstat | 3 files changed, 20 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/html.cc Thu Feb 05 07:43:21 2009 -0300 +++ b/src/html.cc Fri Feb 06 12:36:31 2009 +0100 @@ -456,7 +456,6 @@ InVisitedLink = false; ReqTagClose = false; TagSoup = true; - NameVal = NULL; Num_HTML = Num_HEAD = Num_BODY = Num_TITLE = 0; @@ -2383,11 +2382,24 @@ 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 @@ * 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>" */
--- a/src/html_common.hh Thu Feb 05 07:43:21 2009 -0300 +++ b/src/html_common.hh Fri Feb 06 12:36:31 2009 +0100 @@ -198,7 +198,6 @@ 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;
--- a/src/styleengine.hh Thu Feb 05 07:43:21 2009 -0300 +++ b/src/styleengine.hh Fri Feb 06 12:36:31 2009 +0100 @@ -48,6 +48,7 @@ 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);