mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 03:57:15 +02: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:
committed by
Andreas Kling
parent
64dcd3f1f4
commit
af57bd5cca
Notes:
sideshowbarker
2024-07-16 23:05:02 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/af57bd5cca Pull-request: https://github.com/SerenityOS/serenity/pull/23251 Issue: https://github.com/SerenityOS/serenity/issues/23241
@@ -248,7 +248,7 @@ HTMLToken::Position HTMLTokenizer::nth_last_position(size_t n)
|
||||
return m_source_positions.at(m_source_positions.size() - 1 - n);
|
||||
}
|
||||
|
||||
Optional<HTMLToken> HTMLTokenizer::next_token()
|
||||
Optional<HTMLToken> HTMLTokenizer::next_token(StopAtInsertionPoint stop_at_insertion_point)
|
||||
{
|
||||
if (!m_source_positions.is_empty()) {
|
||||
auto last_position = m_source_positions.last();
|
||||
@@ -263,6 +263,9 @@ _StartOfFunction:
|
||||
return {};
|
||||
|
||||
for (;;) {
|
||||
if (stop_at_insertion_point == StopAtInsertionPoint::Yes && is_insertion_point_reached())
|
||||
return {};
|
||||
|
||||
auto current_input_character = next_code_point();
|
||||
switch (m_state) {
|
||||
// 13.2.5.1 Data state, https://html.spec.whatwg.org/multipage/parsing.html#data-state
|
||||
|
||||
Reference in New Issue
Block a user