mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +00:00
LibWeb: Implement state switch for "[CDATA[" in HTML parser
This commit is contained in:
parent
3f7086f91a
commit
892f6394b8
2 changed files with 14 additions and 1 deletions
|
@ -42,6 +42,8 @@ namespace Web::HTML {
|
||||||
RefPtr<DOM::Document> parse_html_document(StringView, const AK::URL&, const String& encoding);
|
RefPtr<DOM::Document> parse_html_document(StringView, const AK::URL&, const String& encoding);
|
||||||
|
|
||||||
class HTMLParser {
|
class HTMLParser {
|
||||||
|
friend class HTMLTokenizer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HTMLParser(DOM::Document&, StringView input, const String& encoding);
|
HTMLParser(DOM::Document&, StringView input, const String& encoding);
|
||||||
~HTMLParser();
|
~HTMLParser();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -9,8 +10,10 @@
|
||||||
#include <AK/SourceLocation.h>
|
#include <AK/SourceLocation.h>
|
||||||
#include <LibTextCodec/Decoder.h>
|
#include <LibTextCodec/Decoder.h>
|
||||||
#include <LibWeb/HTML/Parser/Entities.h>
|
#include <LibWeb/HTML/Parser/Entities.h>
|
||||||
|
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||||
#include <LibWeb/HTML/Parser/HTMLToken.h>
|
#include <LibWeb/HTML/Parser/HTMLToken.h>
|
||||||
#include <LibWeb/HTML/Parser/HTMLTokenizer.h>
|
#include <LibWeb/HTML/Parser/HTMLTokenizer.h>
|
||||||
|
#include <LibWeb/Namespace.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
@ -394,7 +397,15 @@ _StartOfFunction:
|
||||||
SWITCH_TO(DOCTYPE);
|
SWITCH_TO(DOCTYPE);
|
||||||
}
|
}
|
||||||
if (consume_next_if_match("[CDATA[")) {
|
if (consume_next_if_match("[CDATA[")) {
|
||||||
TODO();
|
// 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_() != Namespace::HTML) {
|
||||||
|
SWITCH_TO(CDATASection);
|
||||||
|
} else {
|
||||||
|
create_new_token(HTMLToken::Type::Comment);
|
||||||
|
m_current_builder.append("[CDATA[");
|
||||||
|
SWITCH_TO_WITH_UNCLEAN_BUILDER(BogusComment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ANYTHING_ELSE
|
ANYTHING_ELSE
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue