[webkit-changes] [WebKit/WebKit] 2e3b48: HTML fast parser fails to parse complex HTML entities

Chris Dumez noreply at github.com
Tue Apr 11 21:44:00 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2e3b48b25a4dbd440e4688ba2ef9dbddc0c6b788
      https://github.com/WebKit/WebKit/commit/2e3b48b25a4dbd440e4688ba2ef9dbddc0c6b788
  Author: Chris Dumez <cdumez at apple.com>
  Date:   2023-04-11 (Tue, 11 Apr 2023)

  Changed paths:
    M Source/WebCore/Headers.cmake
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/dom/ContainerNode.h
    M Source/WebCore/dom/DocumentFragment.h
    M Source/WebCore/html/parser/HTMLDocumentParserFastPath.cpp
    M Source/WebCore/html/parser/HTMLDocumentParserFastPath.h
    M Source/WebCore/html/parser/HTMLEntityParser.cpp
    M Tools/TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp

  Log Message:
  -----------
  HTML fast parser fails to parse complex HTML entities
https://bugs.webkit.org/show_bug.cgi?id=255302

Reviewed by Ryosuke Niwa.

When trying to parse a non-trivial HTML entity such as `¢`, the fast HTML
parser would call `consumeHTMLEntity()` with the string "cent". This would
always fail `notEnoughCharacters` would be set to true. This is because our
parser currently requires data after the HTML entity to make sure we reached
the end of the entity.

To address the issue, the HTML fast parser now includes the trailing semicolon
when calling `consumeHTMLEntity()`. We now pass the string "cent;" for example.
I also tweaked the HTMLEntityParser to not fail with `notEnoughCharacters` if
the last character was a semicolon. In this case, it is safe to assume the
entity was complete, even though we don't know what comes next in the stream.

* Source/WebCore/Headers.cmake:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/dom/DocumentFragment.h:
* Source/WebCore/html/parser/HTMLDocumentParserFastPath.cpp:
(WebCore::HTMLFastPathParser::scanHTMLCharacterReference):
* Source/WebCore/html/parser/HTMLDocumentParserFastPath.h:
* Source/WebCore/html/parser/HTMLEntityParser.cpp:
(WebCore::HTMLEntityParser::consumeNamedEntity):
* Tools/TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/262856@main




More information about the webkit-changes mailing list