aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2016-05-27 10:23:12 -0400
committerJorge Arellano Cid <jcid@dillo.org>2016-05-27 10:23:12 -0400
commitddc060fc1d46b6a4a45c79191f444a4e75def430 (patch)
tree2ee6e4e34e7e58b2f4f0cd7e1a8e1ad9e25d3451
parent91e3b71937b30e0c0ec38de7b5a0a099edf7ce32 (diff)
Don't allow nesting of the A element (fixes slashdot.org).
A lingering open A element can lead to invisible content. e.g. http://slashdot.org/ Note: slashdot_a_bug.html testcase in my HD.
-rw-r--r--src/html.cc12
-rw-r--r--src/html_common.hh3
2 files changed, 10 insertions, 5 deletions
diff --git a/src/html.cc b/src/html.cc
index a3004dba..32ec183c 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -1363,7 +1363,7 @@ static void Html_tag_cleanup_to_idx(DilloHtml *html, int idx)
int toptag_idx = S_TOP(html)->tag_idx;
TagInfo toptag = Tags[toptag_idx];
if (s_sz > idx + 1 && toptag.EndTag != 'O')
- BUG_MSG(" - forcing close of open tag: <%s>.", toptag.name);
+ BUG_MSG("Bad nesting - forcing close of open tag: <%s>.",toptag.name);
_MSG("Close: %s sz=%d idx=%d\n", toptag.name, s_sz, idx);
if (toptag_idx == i_BODY &&
!((html->InFlags & IN_EOF) || html->ReqTagClose)) {
@@ -1393,7 +1393,8 @@ static void Html_tag_cleanup_to_idx(DilloHtml *html, int idx)
*/
static void Html_tag_cleanup_at_close(DilloHtml *html, int new_idx)
{
- static int i_BUTTON = a_Html_tag_index("button"),
+ static int i_A = a_Html_tag_index("a"),
+ i_BUTTON = a_Html_tag_index("button"),
i_SELECT = a_Html_tag_index("select"),
i_TEXTAREA = a_Html_tag_index("textarea");
int w3c_mode = !prefs.w3c_plus_heuristics;
@@ -1411,10 +1412,11 @@ static void Html_tag_cleanup_at_close(DilloHtml *html, int new_idx)
} else if (Tags[tag_idx].EndTag == 'O') {
/* skip an optional tag */
continue;
- } else if ((new_idx == i_BUTTON && html->InFlags & IN_BUTTON) ||
+ } else if ((new_idx == i_A && html->InFlags & IN_A) ||
+ (new_idx == i_BUTTON && html->InFlags & IN_BUTTON) ||
(new_idx == i_SELECT && html->InFlags & IN_SELECT) ||
(new_idx == i_TEXTAREA && html->InFlags & IN_TEXTAREA)) {
- /* let these elements close tags inside them */
+ /* Let these elements close anything left open inside them */
continue;
} else if (w3c_mode || Tags[tag_idx].TagLevel >= new_tag.TagLevel) {
/* this is the tag that should have been closed */
@@ -2783,6 +2785,7 @@ static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize)
const char *attrbuf;
/* TODO: add support for MAP with A HREF */
+ html->InFlags |= IN_A;
if (html->InFlags & IN_MAP)
Html_tag_content_area(html, tag, tagsize);
@@ -2848,6 +2851,7 @@ static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize)
*/
static void Html_tag_close_a(DilloHtml *html)
{
+ html->InFlags &= ~IN_A;
html->InVisitedLink = false;
}
diff --git a/src/html_common.hh b/src/html_common.hh
index 6d0d8c62..6f086f5f 100644
--- a/src/html_common.hh
+++ b/src/html_common.hh
@@ -89,7 +89,8 @@ typedef enum {
IN_LI = 1 << 11,
IN_MEDIA = 1 << 12,
IN_META_HACK = 1 << 13,
- IN_EOF = 1 << 14,
+ IN_A = 1 << 14,
+ IN_EOF = 1 << 15,
} DilloHtmlProcessingState;
/*