1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

LibWeb: Be more forgiving when adding source positions in HTMLTokenizer

This patch changes HTMLTokenizer::nth_last_position to not fail if the
requested position is not available. Rather, it will just return (0-0).

While this is not the correct solution, it prevents the tokenizer from
crashing just because it cannot find a source position. This should only
affect SyntaxHighlighter.
This commit is contained in:
Max Wipfli 2021-06-04 11:31:43 +02:00 committed by Ali Mohammad Pur
parent 93d830b5cc
commit 932161e581
3 changed files with 16 additions and 5 deletions

View file

@ -147,7 +147,7 @@ private:
bool consumed_as_part_of_an_attribute() const;
void restore_to(const Utf8CodePointIterator& new_iterator);
auto& nth_last_position(size_t n = 0) { return m_source_positions.at(m_source_positions.size() - 1 - n); }
HTMLToken::Position nth_last_position(size_t n = 0);
State m_state { State::Data };
State m_return_state { State::Data };