1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 12:07:45 +00:00

LibWeb: Check for valid names in Document.createElement() & friends

We now validate that the provided tag names are valid XML tag names,
and otherwise throw an "invalid character" DOM exception.

2% progression on ACID3. :^)
This commit is contained in:
Andreas Kling 2022-02-26 10:00:49 +01:00
parent 8daf603f46
commit fe67fe3791
7 changed files with 82 additions and 24 deletions

View file

@ -177,8 +177,8 @@ public:
JS::Value run_javascript(StringView source, StringView filename = "(unknown)");
NonnullRefPtr<Element> create_element(const String& tag_name);
NonnullRefPtr<Element> create_element_ns(const String& namespace_, const String& qualified_name);
ExceptionOr<NonnullRefPtr<Element>> create_element(const String& tag_name);
ExceptionOr<NonnullRefPtr<Element>> create_element_ns(const String& namespace_, const String& qualified_name);
NonnullRefPtr<DocumentFragment> create_document_fragment();
NonnullRefPtr<Text> create_text_node(const String& data);
NonnullRefPtr<Comment> create_comment(const String& data);
@ -316,6 +316,8 @@ public:
void set_parser(Badge<HTML::HTMLParser>, HTML::HTMLParser&);
void detach_parser(Badge<HTML::HTMLParser>);
static bool is_valid_name(String const&);
private:
explicit Document(const AK::URL&);