LibWeb: Fix invalid behaviour of HTMLTokenizer::skip() and restore_to()

skip() is supposed to end up keeping the previous iterator only one
index behind the current one, and restore_to() should actually do the
restore instead of just removing the now-useless source positions.
Fixes #7331.
This commit is contained in:
Ali Mohammad Pur 2021-05-21 11:03:31 +04:30 committed by Andreas Kling
parent 09d09b79b6
commit 1822d6b8ac
Notes: sideshowbarker 2024-07-18 17:38:54 +09:00

View File

@ -203,9 +203,9 @@ Optional<u32> HTMLTokenizer::next_code_point()
void HTMLTokenizer::skip(size_t count)
{
m_prev_utf8_iterator = m_utf8_iterator;
m_source_positions.append(m_source_positions.last());
for (size_t i = 0; i < count; ++i) {
m_prev_utf8_iterator = m_utf8_iterator;
auto code_point = *m_utf8_iterator;
if (code_point == '\n') {
m_source_positions.last().column = 0;
@ -2687,6 +2687,7 @@ void HTMLTokenizer::restore_to(const Utf8CodepointIterator& new_iterator)
TODO();
}
}
m_utf8_iterator = new_iterator;
}
}