Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: b1df66e91dd53bf38a21c041093cde90e959d1cc
https://github.com/WebKit/WebKit/commit/b1df66e91dd53bf38a21c041093cde90e959d1cc
Author: Ellie Epskamp-Hunt <[email protected]>
Date: 2022-10-07 (Fri, 07 Oct 2022)
Changed paths:
M Source/WebCore/contentextensions/ContentExtensionActions.cpp
M Source/WebCore/contentextensions/ContentExtensionActions.h
M Source/WebCore/contentextensions/ContentExtensionError.cpp
M Source/WebCore/contentextensions/ContentExtensionError.h
M Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
M Source/WebKit/UIProcess/API/APIContentRuleListStore.h
M Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm
Log Message:
-----------
Handle competing header rules for Declarative Net Request.
https://bugs.webkit.org/show_bug.cgi?id=246177
rdar://98149238
Reviewed by Timothy Hatcher.
Add a priority field to rules that modify headers. This priority is used to
determine how headers
should be modified if multiple rules want to change the same header. This patch
implements the
behavior Chrome details in their Declarative Net Request documentation:
> If a rule has appended to a header, then lower priority rules can only append
> to that header.
set and remove operations are not permitted
> If a rule has set a header, then lower priority rules cannot further modify
> the header,
except for append rules.
> If a rule has removed a header, then lower priority rules cannot further
> modify the header.
* Source/WebCore/contentextensions/ContentExtensionActions.cpp:
(WebCore::ContentExtensions::ModifyHeadersAction::parse):
Parse the new priority field from the JSON.
(WebCore::ContentExtensions::ModifyHeadersAction::isolatedCopy const):
(WebCore::ContentExtensions::ModifyHeadersAction::isolatedCopy):
(WebCore::ContentExtensions::ModifyHeadersAction::operator== const):
(WebCore::ContentExtensions::ModifyHeadersAction::serialize const):
(WebCore::ContentExtensions::ModifyHeadersAction::deserialize):
When serializing a modify headers action, put the priority at the beginning
of the vector.
Modify the rest of serializing logic to take in account the extra bytes at
the beginning.
(WebCore::ContentExtensions::ModifyHeadersAction::applyToRequest):
(WebCore::ContentExtensions::ModifyHeadersAction::ModifyHeaderInfo::applyToRequest):
Pass around a map that contains headers names to the first operation
applied to that header
{append, set, remove}. Use that map to determine if the current operation
should be applied.
* Source/WebCore/contentextensions/ContentExtensionActions.h:
(WebCore::ContentExtensions::add):
* Source/WebCore/contentextensions/ContentExtensionError.cpp:
(WebCore::ContentExtensions::contentExtensionErrorCategory):
* Source/WebCore/contentextensions/ContentExtensionError.h:
* Source/WebCore/contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::applyResultsToRequest):
Process the header rules from highest priority to lowest.
* Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
(TestWebKitAPI::TEST_F):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm:
(TEST_F):
Add new tests where each rule targets the same header.
Canonical link: https://commits.webkit.org/255298@main
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes