浏览代码

LibWeb: Fix parsing of "<textarea></textarea>"

When handling a "textarea" start tag, we have to ignore the next token
if it's an LF ('\n'). However, we were not switching the tokenizer
state before fetching the lookahead token, and this caused us to force
the tokenizer into the RCDATA state too late, effectively getting it
stuck in that state for way longer than it should be.

Fixes #2508.
Andreas Kling 5 年之前
父节点
当前提交
b4591f0037
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      Libraries/LibWeb/Parser/HTMLDocumentParser.cpp

+ 2 - 1
Libraries/LibWeb/Parser/HTMLDocumentParser.cpp

@@ -1283,12 +1283,13 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
     if (token.is_start_tag() && token.tag_name() == "textarea") {
     if (token.is_start_tag() && token.tag_name() == "textarea") {
         insert_html_element(token);
         insert_html_element(token);
 
 
+        m_tokenizer.switch_to({}, HTMLTokenizer::State::RCDATA);
+
         // If the next token is a U+000A LINE FEED (LF) character token,
         // If the next token is a U+000A LINE FEED (LF) character token,
         // then ignore that token and move on to the next one.
         // then ignore that token and move on to the next one.
         // (Newlines at the start of pre blocks are ignored as an authoring convenience.)
         // (Newlines at the start of pre blocks are ignored as an authoring convenience.)
         auto next_token = m_tokenizer.next_token();
         auto next_token = m_tokenizer.next_token();
 
 
-        m_tokenizer.switch_to({}, HTMLTokenizer::State::RCDATA);
         m_original_insertion_mode = m_insertion_mode;
         m_original_insertion_mode = m_insertion_mode;
         m_frameset_ok = false;
         m_frameset_ok = false;
         m_insertion_mode = InsertionMode::Text;
         m_insertion_mode = InsertionMode::Text;