mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +00:00
LibWeb: Stop parsing after document.write
at the insertion point
If a call to `document.write` inserts an incomplete HTML tag, e.g.: document.write("<p"); we would previously continue parsing the document until we reached a closing angle bracket. However, the spec states we should stop once we reach the new insertion point.
This commit is contained in:
parent
64dcd3f1f4
commit
af57bd5cca
Notes:
sideshowbarker
2024-07-16 23:05:02 +09:00
Author: https://github.com/trflynn89
Commit: af57bd5cca
Pull-request: https://github.com/SerenityOS/serenity/pull/23251
Issue: https://github.com/SerenityOS/serenity/issues/23241
7 changed files with 62 additions and 10 deletions
|
@ -169,14 +169,14 @@ void HTMLParser::visit_edges(Cell::Visitor& visitor)
|
|||
m_list_of_active_formatting_elements.visit_edges(visitor);
|
||||
}
|
||||
|
||||
void HTMLParser::run()
|
||||
void HTMLParser::run(HTMLTokenizer::StopAtInsertionPoint stop_at_insertion_point)
|
||||
{
|
||||
for (;;) {
|
||||
// FIXME: Find a better way to say that we come from Document::close() and want to process EOF.
|
||||
if (!m_tokenizer.is_eof_inserted() && m_tokenizer.is_insertion_point_reached())
|
||||
return;
|
||||
|
||||
auto optional_token = m_tokenizer.next_token();
|
||||
auto optional_token = m_tokenizer.next_token(stop_at_insertion_point);
|
||||
if (!optional_token.has_value())
|
||||
break;
|
||||
auto& token = optional_token.value();
|
||||
|
@ -216,11 +216,11 @@ void HTMLParser::run()
|
|||
flush_character_insertions();
|
||||
}
|
||||
|
||||
void HTMLParser::run(const AK::URL& url)
|
||||
void HTMLParser::run(const AK::URL& url, HTMLTokenizer::StopAtInsertionPoint stop_at_insertion_point)
|
||||
{
|
||||
m_document->set_url(url);
|
||||
m_document->set_source(MUST(String::from_byte_string(m_tokenizer.source())));
|
||||
run();
|
||||
run(stop_at_insertion_point);
|
||||
the_end(*m_document, this);
|
||||
m_document->detach_parser({});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue