소스 검색

LibWeb: Bail nicely on EOF in HTML parser "in body" state

If we reach the end of the token stream when "ignoring and moving on
to the next token" in the "in body" state, we should just not move
on to the next token, since there isn't one.

Covered by various WPT HTML parsing tests that will be imported in
a subsequent commit.
Andreas Kling 8 달 전
부모
커밋
cfa820922b
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp

+ 2 - 2
Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp

@@ -1912,7 +1912,7 @@ void HTMLParser::handle_in_body(HTMLToken& token)
         auto next_token = m_tokenizer.next_token();
         auto next_token = m_tokenizer.next_token();
         if (next_token.has_value() && next_token.value().is_character() && next_token.value().code_point() == '\n') {
         if (next_token.has_value() && next_token.value().is_character() && next_token.value().code_point() == '\n') {
             // Ignore it.
             // Ignore it.
-        } else {
+        } else if (next_token.has_value()) {
             process_using_the_rules_for(m_insertion_mode, next_token.value());
             process_using_the_rules_for(m_insertion_mode, next_token.value());
         }
         }
 
 
@@ -2471,7 +2471,7 @@ void HTMLParser::handle_in_body(HTMLToken& token)
         // FIXME: This step is not in the spec.
         // FIXME: This step is not in the spec.
         if (next_token.has_value() && next_token.value().is_character() && next_token.value().code_point() == '\n') {
         if (next_token.has_value() && next_token.value().is_character() && next_token.value().code_point() == '\n') {
             // Ignore it.
             // Ignore it.
-        } else {
+        } else if (next_token.has_value()) {
             process_using_the_rules_for(m_insertion_mode, next_token.value());
             process_using_the_rules_for(m_insertion_mode, next_token.value());
         }
         }
         return;
         return;