Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: b60c1a321a03a8912f9b8511018525271477aefc
https://github.com/WebKit/WebKit/commit/b60c1a321a03a8912f9b8511018525271477aefc
Author: Wenson Hsieh <[email protected]>
Date: 2022-11-02 (Wed, 02 Nov 2022)
Changed paths:
M Source/WebCore/contentextensions/ContentExtensionActions.cpp
M Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp
Log Message:
-----------
[Content Extensions] QueryTransforms should not unconditionally redirect to
form-encoded URLs
https://bugs.webkit.org/show_bug.cgi?id=247365
Reviewed by Tim Horton and Timothy Hatcher.
Refactor `QueryTransform::applyToURL`, so that it doesn't unconditionally call
into
`parseURLEncodedForm()`, and set the query to this URL-encoded form. Currently,
this causes query
parameters and values in the input URL to become percent-encoded, regardless of
whether or not any
of the query transformation rules matched.
Instead, we change this behavior to leave query parameters intact, in the case
where they don't
match any of the query transformation rules. This means that if a URL query
contains `"x+y=z"` and
it doesn't match any transformation rules, the final result will remain as-is,
rather than
`"x%20y=z"`.
Test: ContentExtensionTest.QueryTransformActions
* Source/WebCore/contentextensions/ContentExtensionActions.cpp:
Also, add an early return in the case where the URL has no query parameters at
all, so that we can
avoid spending any time checking against rules. We also avoid calling
`setQuery` at all in the case
where no actions were applied, so that we don't need to unnecessarily re-parse
the URL if nothing
changed.
(WebCore::ContentExtensions::RedirectAction::URLTransformAction::QueryTransform::applyToURL
const):
* Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
Add an API test to exercise the bug.
Canonical link: https://commits.webkit.org/256260@main
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes