Skip to content

[Feature Request] Allow URL Regular Expressions to Match Query String #101

Description

@kapinga

I am a long-time user of BrowseRouter (and before it, BrowserSelector) to route links to my work domains into Edge and ~everything else into FireFox. Thank you for your work maintaining and expanding this application!

My employer uses email link checking and, importantly, I do not want to disable these checks (as is offered by the "filter" capability). Previously, we've used ProofPoint, which embeds the destination URL as part of the URI's Path (e.g. "https://urldefense.com/v3/__https://www.microsoft.com") . I was able to write a series of URL regexes to evaluate the destination path and select the right browser.

My employer has recently switched to using Outlook safelinks, which embeds the destination URL as a query term. After some testing, I determined that any regex url which references any part of the URI's query (e.g. "/.*\\.safelinks\\.protection\\.outlook\\.com/[^?]*\\?url=/") will never match. This is implemented in UrlPreferenceExtensions.GetDomainAndPattern, which explicitly only includes the URI's Authority and AbsolutePath. To your credit, the README documents that regex URLs use the domain and path, although it does not make clear that the query is not considered.

UrlPreferenceExtensions also defines an undocumented format offset by ? characters that does include the query but only permits simple wildcards (each * is expanded to .* while all other regex special characters are escaped). This works for simple domain checks, but does not work reliably on anything more advanced (i.e., there's no way to do a wildcard match on "*.contoso.com" without also potentially matching "www.evilsite.com/contoso.com"). Obviously, choosing the wrong browser is not a safety consideration, but it is an annoyance.

I'm requesting some way to enable arbitrary regular expressions to be evaluated against URLs that include the query (and probably the fragment too). I envision this either as a global option (e.g. "includeQueryInRegex") that defaults to false and applies to all URL regexes, or provide yet another syntax (perhaps using |) to define those matches on a case-by-case basis. I'm happy to contribute ideas on the design if you're interested in it, but do not have a C# toolchain set up to do much development myself.

(Tagging @nref for visibility, as noted in CONTRIBUTING.md).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions