mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +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:
parent
8daf603f46
commit
fe67fe3791
7 changed files with 82 additions and 24 deletions
|
@ -53,21 +53,21 @@ static bool build_markdown_document(DOM::Document& document, const ByteBuffer& d
|
|||
|
||||
static bool build_text_document(DOM::Document& document, const ByteBuffer& data)
|
||||
{
|
||||
auto html_element = document.create_element("html");
|
||||
auto html_element = document.create_element("html").release_value();
|
||||
document.append_child(html_element);
|
||||
|
||||
auto head_element = document.create_element("head");
|
||||
auto head_element = document.create_element("head").release_value();
|
||||
html_element->append_child(head_element);
|
||||
auto title_element = document.create_element("title");
|
||||
auto title_element = document.create_element("title").release_value();
|
||||
head_element->append_child(title_element);
|
||||
|
||||
auto title_text = document.create_text_node(document.url().basename());
|
||||
title_element->append_child(title_text);
|
||||
|
||||
auto body_element = document.create_element("body");
|
||||
auto body_element = document.create_element("body").release_value();
|
||||
html_element->append_child(body_element);
|
||||
|
||||
auto pre_element = document.create_element("pre");
|
||||
auto pre_element = document.create_element("pre").release_value();
|
||||
body_element->append_child(pre_element);
|
||||
|
||||
pre_element->append_child(document.create_text_node(String::copy(data)));
|
||||
|
@ -85,22 +85,22 @@ static bool build_image_document(DOM::Document& document, ByteBuffer const& data
|
|||
if (!bitmap)
|
||||
return false;
|
||||
|
||||
auto html_element = document.create_element("html");
|
||||
auto html_element = document.create_element("html").release_value();
|
||||
document.append_child(html_element);
|
||||
|
||||
auto head_element = document.create_element("head");
|
||||
auto head_element = document.create_element("head").release_value();
|
||||
html_element->append_child(head_element);
|
||||
auto title_element = document.create_element("title");
|
||||
auto title_element = document.create_element("title").release_value();
|
||||
head_element->append_child(title_element);
|
||||
|
||||
auto basename = LexicalPath::basename(document.url().path());
|
||||
auto title_text = adopt_ref(*new DOM::Text(document, String::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height())));
|
||||
title_element->append_child(title_text);
|
||||
|
||||
auto body_element = document.create_element("body");
|
||||
auto body_element = document.create_element("body").release_value();
|
||||
html_element->append_child(body_element);
|
||||
|
||||
auto image_element = document.create_element("img");
|
||||
auto image_element = document.create_element("img").release_value();
|
||||
image_element->set_attribute(HTML::AttributeNames::src, document.url().to_string());
|
||||
body_element->append_child(image_element);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue