I’ve noticed that redirecting from one web page to another using DNR (Declarative Net Request) no longer works if:
- The source page is a search results page of the default search engine, and
- The user searches for a keyword from Safari’s address bar.
Has this functionality been degraded, or is it an intentional restriction?
I'd like a response from Apple.
Steps to Reproduce
- Create a Safari extension that adds the following rule using
browser.declarativeNetRequest.updateSessionRules()
inbackground.js
:{ id: 37457985, priority: 1, action: { type: "redirect", redirect: { regexSubstitution: "https://search.brave.com/search?q=\\1" }, }, condition: { regexFilter: "https://duckduckgo.com/\\?(?:.*&)?q=([^&]*).*", resourceTypes: ["main_frame"] } }
- Enable the extension in Safari.
- Set Safari’s default search engine to DuckDuckGo.
- Type "hello" in the address bar to search for it.
Expected:
Search results for "hello" appear in Brave Search.
Actual:
Safari navigates to neither DuckDuckGo nor Brave Search.
For further reference, please see:
- Sample Xcode project: GitHub link
- Demo video: GitHub link
Environment
I’ve confirmed this issue on the following environments:
- Safari Technology Preview 202 (macOS Sonoma 14.6.1 (23G93))
- iOS 18 RC (22A3354)
This issue does not occur in the latest release version of Safari 17.6 (19618.3.11.11.5) on macOS, so I believe it started with the current development version of Safari.
Context
My Safari extension, Redirect Web for Safari, uses DNR to redirect one web page to another. While the extension is not specifically designed to change the default search engine, some users use it to set their preferred search engine. Unfortunately, this issue will break their use case.
Additional Information
- This issue only occurs when searching from the address bar. It does not happen when searching directly from https://duckduckgo.com.
- I haven’t submitted this issue via Feedback Assistant because I’m unsure if it’s a bug or intentional behavior. I’d like to confirm if this is by design first.