[webkit-changes] [WebKit/WebKit] c86476: WebCore::XMLDocumentParserScope does not restore x...

Commit Queue noreply at github.com
Mon May 6 19:01:42 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c864765c693d31b70ece9a455e7b82b413041a6a
      https://github.com/WebKit/WebKit/commit/c864765c693d31b70ece9a455e7b82b413041a6a
  Author: David Kilzer <ddkilzer at apple.com>
  Date:   2024-05-06 (Mon, 06 May 2024)

  Changed paths:
    M Source/WebCore/xml/parser/XMLDocumentParserScope.cpp
    M Source/WebCore/xml/parser/XMLDocumentParserScope.h
    M Tools/TestWebKitAPI/Tests/WebCore/cocoa/XMLParsing.mm

  Log Message:
  -----------
  WebCore::XMLDocumentParserScope does not restore xmlStructuredErrorContext properly
<https://bugs.webkit.org/show_bug.cgi?id=273665>
<rdar://127468626>

Reviewed by Alex Christensen.

Prior to this change, XMLDocumentParserScope would restore
xmlStructuredErrorContext using the saved value of
xmlGenericErrorContext.

The fix is to store the original value of xmlStructuredErrorContext in
its own instance variable so it can be restored separately.

If the structuredErrorContext parameter is not set when calling the
XMLDocumentParserScope() constructor, the value of genericErrorContext
is used for structuredErrorContext (as before).

API Test:
    TestWebKitAPI.XMLParsing.WebCoreRestoresLibxml2GenericAndStructuredErrorState

* Source/WebCore/xml/parser/XMLDocumentParserScope.cpp:
(WebCore::XMLDocumentParserScope::XMLDocumentParserScope):
- Add structuredErrorContext argument to constructor so that the
  single-argument constructor can pass in the correct value.
- Store xmlStructuredErrorContext in m_oldStructuredErrorContext.
- Set the structuredErrorContext using that argument, or fall back to
  genericErrorContext if structuredErrorContext is nullptr.
(WebCore::XMLDocumentParserScope::~XMLDocumentParserScope):
- Properly restore saved structuredErrorContext in
  m_oldStructuredErrorContext in the destructor.
* Source/WebCore/xml/parser/XMLDocumentParserScope.h:
(WebCore::XMLDocumentParserScope::XMLDocumentParserScope):
- Declare optional structuredErrorContext argument.
- Rename m_oldErrorContext to m_oldGenericErrorContext.
- Add m_oldStructuredErrorContext.

* Tools/TestWebKitAPI/Tests/WebCore/cocoa/XMLParsing.mm:
(TestWebKitAPI::TEST_F(XMLParsing, WebCoreRestoresLibxml2GenericAndStructuredErrorState)): Add.
- Add test for this change.

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list