Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 301771c71cc7b6b56aa1e2567926fc71d927d459
https://github.com/WebKit/WebKit/commit/301771c71cc7b6b56aa1e2567926fc71d927d459
Author: Elijah Sawyers <[email protected]>
Date: 2025-04-15 (Tue, 15 Apr 2025)
Changed paths:
M Source/WebCore/contentextensions/ContentExtensionError.cpp
M Source/WebCore/contentextensions/ContentExtensionError.h
M Source/WebCore/contentextensions/ContentExtensionParser.cpp
M Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
M Source/WebCore/contentextensions/ContentExtensionsBackend.h
M Source/WebCore/contentextensions/DFABytecode.h
M Source/WebCore/contentextensions/DFABytecodeCompiler.cpp
M Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp
M Source/WebCore/loader/ResourceLoadInfo.cpp
M Source/WebCore/loader/ResourceLoadInfo.h
M Source/WebKit/NetworkProcess/NetworkLoadChecker.cpp
M Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp
M Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentRuleListNotification.mm
Log Message:
-----------
Implement request methods content blocker trigger field
https://bugs.webkit.org/show_bug.cgi?id=290962
rdar://148474901
Reviewed by Alex Christensen.
This patch introduces a new trigger field, request-method, to perform an action
only if the HTTP request method matches the specified HTTP request method. This
field has a string value, which can be any of the HTTP methods (lowercased) as
defined by:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Methods
We chose to use a string value, rather than an array of strings, because making
the request methods mutually exclusive saves more space (4 bits instead of 9).
Although this pattern deviates from the trigger field norm, it's better to save
the bits since we're running out of room.
The motivation behind this change is that we need to support requestMethods and
excludedRequestMethods in dNR, which isn't possible without this change.
* Source/WebCore/contentextensions/ContentExtensionError.cpp:
(WebCore::ContentExtensions::contentExtensionErrorCategory):
* Source/WebCore/contentextensions/ContentExtensionError.h:
Introduce a new error for invalid request-method field.
* Source/WebCore/contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::loadTrigger):
Parse the request-method into the trigger flags, raising an error as needed.
* Source/WebCore/contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad):
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForPingLoad):
Parse the HTTP request method of the load and include it in the resource load
info.
* Source/WebCore/contentextensions/ContentExtensionsBackend.h:
Make the method for processing content rule lists for ping loads take in an HTTP
method parameter.
* Source/WebCore/contentextensions/DFABytecode.h:
* Source/WebCore/contentextensions/DFABytecodeCompiler.cpp:
(WebCore::ContentExtensions::bytecodeFlagsSize):
(WebCore::ContentExtensions::toSizeT):
* Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp:
(WebCore::ContentExtensions::consumeResourceFlagsAndInstruction):
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpretTestFlagsAndAppendAction):
Introduce a 32 bit flags size. With the introduction of request methods, the
flags can be up to 25 bits in size.
* Source/WebCore/loader/ResourceLoadInfo.cpp:
(WebCore::ContentExtensions::readRequestMethod):
(WebCore::ContentExtensions::ResourceLoadInfo::getResourceFlags const):
* Source/WebCore/loader/ResourceLoadInfo.h:
(WebCore::ContentExtensions::ResourceLoadInfo::isolatedCopy const):
(WebCore::ContentExtensions::ResourceLoadInfo::isolatedCopy):
Introduce the request methods enum, and modify the byte code as necessary.
* Source/WebKit/NetworkProcess/NetworkLoadChecker.cpp:
(WebKit::NetworkLoadChecker::processContentRuleListsForLoad):
Pass in the HTTP method when processing content rule lists for ping load.
* Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
(TestWebKitAPI::TEST_F(ContentExtensionTest, RequestMethod)):
Write a new test for validating the behavior of the request-method field.
(TestWebKitAPI::TEST_F(ContentExtensionTest, InvalidJSON)):
Add assertions for validating the request-method field in the JSON.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentRuleListNotification.mm:
(TEST(ContentRuleList, RequestMethods)):
Write a new test for validating the behavior of the request-method field.
Canonical link: https://commits.webkit.org/293746@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes