From 88908be350594c75ff1ceb9291a37d1bec1656a5 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 18 Apr 2020 20:33:28 +0200 Subject: [PATCH] LibWeb: Parse
into a self-closed br element We were parsing "
" as an open tag with the name "br/". This fixes that specific scenario. We also rename is_self_closing_tag() to is_void_element() to better fit the specs. --- Libraries/LibWeb/Parser/HTMLParser.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Libraries/LibWeb/Parser/HTMLParser.cpp b/Libraries/LibWeb/Parser/HTMLParser.cpp index 91afd58f50..25eaa237fd 100644 --- a/Libraries/LibWeb/Parser/HTMLParser.cpp +++ b/Libraries/LibWeb/Parser/HTMLParser.cpp @@ -45,7 +45,7 @@ static bool is_valid_in_attribute_name(char ch) return isalnum(ch) || ch == '_' || ch == '-'; } -static bool is_self_closing_tag(const StringView& tag_name) +static bool is_void_element(const StringView& tag_name) { return tag_name == "area" || tag_name == "base" @@ -133,7 +133,7 @@ static bool parse_html_document(const StringView& html, Document& document, Pare node_stack[node_stack.size() - 2].append_child(new_element); } - if (is_self_closing_tag(new_element->tag_name())) + if (is_void_element(new_element->tag_name())) close_tag(); }; @@ -258,6 +258,13 @@ static bool parse_html_document(const StringView& html, Document& document, Pare move_to_state(State::InAttributeList); break; } + if (ch == '/' && peek(1) == '>') { + open_tag(); + close_tag(); + i += 1; + move_to_state(State::Free); + break; + } if (ch == '>') { commit_tag(); move_to_state(State::Free);