Safari DNR Redirect Issue When Using Address Bar for Default Search Engine Queries

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

  1. Create a Safari extension that adds the following rule using browser.declarativeNetRequest.updateSessionRules() in background.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"]
      }
    }
    
  2. Enable the extension in Safari.
  3. Set Safari’s default search engine to DuckDuckGo.
  4. 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:

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.

I'm actually seeing the opposite results: your sample extension works for me in Safari Technology Preview 202 but does not work in Safari 17.6.

@jeffjohnson Thanks for checking it. I see, tthat's strange. I still haven't seen the sample extension working correctly on Safari Technology Preview 202. I've tried to make it work for 30 minutes, but it never does.

By the way, I also succeeded in replicating this issue on Safari 17.6. Specifically, when I search from the address bar for the first time in a new tab, it correctly redirects to Brave. However, after that, it doesn't work with the same tab. This is the demo:
https://github.com/user-attachments/assets/c8a84403-c878-44a5-8748-91721c0ea66b

It works again when I open another new tab.

So, on my end, the issue seems to have worsened rather than newly appeared.

Safari DNR Redirect Issue When Using Address Bar for Default Search Engine Queries
 
 
Q