Bug 244475
| Summary: | declarativeNetRequest in web extensions does not support regexSubstitution | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | vsr4493 |
| Component: | WebKit Extensions | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Blocker | CC: | achristensen, luke.selker, timothy, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari Technology Preview | ||
| Hardware: | Mac (Apple Silicon) | ||
| OS: | Unspecified | ||
vsr4493
Was looking into usage for declarativeNetRequest permission to configure redirects.
Expected behaviour: We should be able to add a dynamic redirect rule with a regexFilter and a regexSubstitution for the action.
Current behaviour: we get an error message that reads "`redirect` is missing either a `url`, `extensionPath`, or `transform` key" implying that regex substitution is not supported.
Sample payload:
```
browser.declarativeNetRequest.updateDynamicRules({ addRules: [
{
action: {redirect: {regexSubstitution: "https://www.somesite.com/\\1"}, type: "redirect"},
condition: {regexFilter: ".*?://test/(.*?)", resourceTypes: ["main_frame"]},
priority: 1,
id: 1,
}
]})
```
Other notes:
- Looking at these i see regexSubstitution should be supported, but i'm unable to determine where this pre-emptive check is happening:
https://github.com/WebKit/WebKit/blob/dd956d5e74249681ddf904e0bbe401f308b65e0f/Source/WebCore/contentextensions/ContentExtensionActions.cpp#L302
https://github.com/WebKit/WebKit/blob/2414d35395c931a94b7b8cedf131a2ca17fd8566/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp#L3103
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
vsr4493
Scope: Safari web extensions
API: declarativeNetRequest
Issue: Unexpected behaviour / missing functionality when calling updateDynamicRules()
Radar WebKit Bug Importer
<rdar://problem/99560504>
luke.selker
Hi, just wondering if there has been any investigation into this issue now that there is more support being published for Declarative Net Request. I'm still seeing the issue in version 16.4
Timothy Hatcher
This should wor in Safari Technology Preview. It has not shipped in Safari yet.
luke.selker
Thanks Timothy! I was able to confirm this is working in Safari Technology Preview. Do you have details on when Safari Technology Preview Releases get merged into production?
vsr4493
Closing this as I see this was included in Technology preview and will likely be out soon on Safari stable. Thanks!