From c36db35b2b8704eb36bc341cd99abac01abfab87 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 20 Apr 2021 22:56:59 -0400 Subject: [PATCH] fix(custom-protocol): Make sure custom protocol on Windows is over HTTPS. (#179) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I thought we’ll get a SSL error but after my tests I figured out we should use https instead of http. --- .changes/windows-ssl-custom-protocol.md | 5 +++++ src/webview/win32/mod.rs | 6 +++--- src/webview/winrt/mod.rs | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changes/windows-ssl-custom-protocol.md diff --git a/.changes/windows-ssl-custom-protocol.md b/.changes/windows-ssl-custom-protocol.md new file mode 100644 index 000000000..987a09631 --- /dev/null +++ b/.changes/windows-ssl-custom-protocol.md @@ -0,0 +1,5 @@ +--- +"wry": minor +--- + +Make sure custom protocol on Windows is over HTTPS. diff --git a/src/webview/win32/mod.rs b/src/webview/win32/mod.rs index f809558d6..cc9f2464e 100644 --- a/src/webview/win32/mod.rs +++ b/src/webview/win32/mod.rs @@ -117,7 +117,7 @@ impl InnerWebView { // See https://github.com/MicrosoftEdge/WebView2Feedback/issues/73 custom_protocol_names.insert(name.clone()); w.add_web_resource_requested_filter( - &format!("http://custom-protocol-{}*", name), + &format!("https://custom-protocol-{}*", name), webview2::WebResourceContext::All, )?; let env_clone = env_.clone(); @@ -125,7 +125,7 @@ impl InnerWebView { let uri = args.get_request()?.get_uri()?; // Undo the protocol workaround when giving path to resolver let path = &uri.replace( - &format!("http://custom-protocol-{}", name), + &format!("https://custom-protocol-{}", name), &format!("{}://", name), ); @@ -175,7 +175,7 @@ impl InnerWebView { // See https://github.com/MicrosoftEdge/WebView2Feedback/issues/73 url_string = url.as_str().replace( &format!("{}://", name), - &format!("http://custom-protocol-{}", name), + &format!("https://custom-protocol-{}", name), ) } w.navigate(&url_string)?; diff --git a/src/webview/winrt/mod.rs b/src/webview/winrt/mod.rs index ee6127caa..d85c6bcd4 100644 --- a/src/webview/winrt/mod.rs +++ b/src/webview/winrt/mod.rs @@ -141,7 +141,7 @@ impl InnerWebView { // See https://github.com/MicrosoftEdge/WebView2Feedback/issues/73 custom_protocol_names.insert(name.clone()); w.AddWebResourceRequestedFilter( - format!("http://custom-protocol-{}*", name).as_str(), + format!("https://custom-protocol-{}*", name).as_str(), webview2::CoreWebView2WebResourceContext::All, )?; let env_ = env.clone(); @@ -154,7 +154,7 @@ impl InnerWebView { if let Ok(uri) = String::from_utf16(args.Request()?.Uri()?.as_wide()) { // Undo the protocol workaround when giving path to resolver let path = uri.replace( - &format!("http://custom-protocol-{}", name), + &format!("https://custom-protocol-{}", name), &format!("{}://", name), ); @@ -208,7 +208,7 @@ impl InnerWebView { // See https://github.com/MicrosoftEdge/WebView2Feedback/issues/73 url_string = url.as_str().replace( &format!("{}://", name), - &format!("http://custom-protocol-{}", name), + &format!("https://custom-protocol-{}", name), ) } w.Navigate(url_string.as_str())?;