LibWeb: Make HTML parser "current node" APIs return nullable pointer

It's actually possible for there to be no adjusted current node, when
the stack of open elements is empty. This was covered by one of the WPT
parsing tests.
This commit is contained in:
Andreas Kling 2024-11-03 19:50:13 +01:00 committed by Andreas Kling
commit 64747c0397
Notes: github-actions[bot] 2024-11-03 19:33:21 +00:00
5 changed files with 117 additions and 78 deletions

View file

@ -433,7 +433,9 @@ _StartOfFunction:
if (consume_next_if_match("[CDATA["sv)) {
// We keep the parser optional so that syntax highlighting can be lexer-only.
// The parser registers itself with the lexer it creates.
if (m_parser != nullptr && m_parser->adjusted_current_node().namespace_uri() != Namespace::HTML) {
if (m_parser != nullptr
&& m_parser->adjusted_current_node()
&& m_parser->adjusted_current_node()->namespace_uri() != Namespace::HTML) {
SWITCH_TO(CDATASection);
} else {
create_new_token(HTMLToken::Type::Comment);