mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 04:24:59 +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
7 changed files with 62 additions and 10 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue