Skip to content

[Problem/Bug]: CustomScheme name matching might be too lenient #5496

@dansoper

Description

@dansoper

What happened?

I have a CoreWebView2CustomSchemeRegistration with the SchemeName set to myscheme.

This works fine, and requests to myscheme://file.txt come through correctly.

However, if I expand the scheme, for example myschemeextra://file.txt, this comes through too, even though I haven't registered myschemeextra as a scheme.

Is this to be expected?

Importance

Moderate. My app's user experience is affected, but still usable.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

144.0.3719.82

SDK Version

1.0.2849.39

Framework

Winforms

Operating System

Windows 11

OS Version

26200.7623

Repro steps

Register a scheme like this

var customSchemeRegistration = new CoreWebView2CustomSchemeRegistration("myscheme");
customSchemeRegistration.HasAuthorityComponent = false;
var envOptions = new CoreWebView2EnvironmentOptions("--disable-web-security --disable-site-isolation-trials", customSchemeRegistrations: new List<CoreWebView2CustomSchemeRegistration>() { customSchemeRegistration });

Add a handler

webView.CoreWebView2.WebResourceRequested += CoreWebView2_WebResourceRequested;
private void CoreWebView2_WebResourceRequested(object sender, CoreWebView2WebResourceRequestedEventArgs e)
{
    // check e.Request.Uri here
}

Verify that the CoreWebView2_WebResourceRequested method receives requests for myscheme:// and myschemeextra:// URLs, but not somethingelse:// URLs.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

Don't know

Last working version (if regression)

No response

AB#60843623

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtrackedWe are tracking this work internally.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions