The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(app): exempt only the configured Windows app scheme
M3gA-Mind83d45308cabb
diff --git a/crates/openhuman-app/src/external_navigation.rs b/crates/openhuman-app/src/external_navigation.rsindex 0141cc7b6d..388a9a38d2 100644--- a/crates/openhuman-app/src/external_navigation.rs+++ b/crates/openhuman-app/src/external_navigation.rs@@ -26,18 +26,26 @@ const MAIN_WINDOW: &str = "main";/// App origins that stay in the webview:/// - any non-`http(s)` scheme: `tauri://localhost` (macOS/Linux), `about:`,/// `blob:`, `data:`;-/// - `http(s)://tauri.localhost` on its default port (Windows); any other port-/// is a different origin, e.g. a loopback service, and is handed off;+/// - `<windows_scheme>://tauri.localhost` on its default port (Windows), where+/// `windows_scheme` is `https` only when the window sets `useHttpsScheme`;+/// the other scheme or any other port is a different origin (e.g. a loopback+/// service) and is handed off;/// - the dev server origin, passed as `dev_url` only under `tauri dev`.-pub(crate) fn navigation_handoff(label: &str, url: &Url, dev_url: Option<&Url>) -> Option<Url> {+pub(crate) fn navigation_handoff(+ label: &str,+ url: &Url,+ windows_scheme: &str,+ dev_url: Option<&Url>,+) -> Option<Url> {if label != MAIN_WINDOW || !matches!(url.scheme(), "http" | "https") {return None;}// `Url` drops a scheme's default port, so `port()` is `None` only for the- // canonical `http(s)://tauri.localhost` origins.- if (url.host_str() == Some("tauri.localhost") && url.port().is_none())- || dev_url.is_some_and(|dev| dev.origin() == url.origin())- {+ // canonical origin.+ let is_windows_app_origin = url.scheme() == windows_scheme+ && url.host_str() == Some("tauri.localhost")+ && url.port().is_none();+ if is_windows_app_origin || dev_url.is_some_and(|dev| dev.origin() == url.origin()) {return None;}Some(url.clone())@@ -51,7 +59,16 @@ pub(crate) fn init<R: Runtime>() -> TauriPlugin<R> {} else {None};- let Some(target) = navigation_handoff(webview.label(), url, dev_url.as_ref()) else {+ let https = webview+ .config()+ .app+ .windows+ .iter()+ .any(|w| w.label == webview.label() && w.use_https_scheme);+ let windows_scheme = if https { "https" } else { "http" };+ let Some(target) =+ navigation_handoff(webview.label(), url, windows_scheme, dev_url.as_ref())+ else {return true;};// Origin only: the path and query can carry tokens or user content.diff --git a/crates/openhuman-app/src/external_navigation_tests.rs b/crates/openhuman-app/src/external_navigation_tests.rsindex 96f0b66ac8..4138e2e619 100644--- a/crates/openhuman-app/src/external_navigation_tests.rs+++ b/crates/openhuman-app/src/external_navigation_tests.rs@@ -14,9 +14,11 @@ fn remote_pages_are_cancelled_and_handed_to_the_os_browser() {"https://tauri.localhost.example.com/",// Same host, different origin: a loopback service on another port."http://tauri.localhost:8000/",+ // Same host, other scheme than the app is configured with (`useHttpsScheme` unset).+ "https://tauri.localhost/",] {assert_eq!(- navigation_handoff("main", &url(href), None),+ navigation_handoff("main", &url(href), "http", None),Some(url(href)),"{href} must not load in the main webview");@@ -28,29 +30,55 @@ fn app_origins_stay_in_the_main_webview() {for href in ["tauri://localhost/#/chat","http://tauri.localhost/#/chat",- "https://tauri.localhost/#/settings","about:blank","data:text/html,<p>hi</p>","blob:tauri://localhost/5e1c",] {- assert_eq!(navigation_handoff("main", &url(href), None), None, "{href}");+ assert_eq!(+ navigation_handoff("main", &url(href), "http", None),+ None,+ "{href}"+ );}}+#[test]+fn windows_app_origin_follows_the_configured_scheme() {+ assert_eq!(+ navigation_handoff(+ "main",+ &url("https://tauri.localhost/#/chat"),+ "https",+ None+ ),+ None+ );+ assert!(+ navigation_handoff("main", &url("http://tauri.localhost/#/chat"), "https", None).is_some()+ );+}+#[test]fn dev_server_is_an_app_origin_only_when_it_is_the_dev_url() {let dev = url("http://localhost:1420");assert_eq!(- navigation_handoff("main", &url("http://localhost:1420/#/chat"), Some(&dev)),+ navigation_handoff(+ "main",+ &url("http://localhost:1420/#/chat"),+ "http",+ Some(&dev)+ ),None);- assert!(navigation_handoff("main", &url("http://localhost:1420/#/chat"), None).is_some());+ assert!(+ navigation_handoff("main", &url("http://localhost:1420/#/chat"), "http", None).is_some()+ );}#[test]fn other_webviews_are_left_to_their_own_handlers() {assert_eq!(- navigation_handoff("ptt-overlay", &url("https://github.com/"), None),+ navigation_handoff("ptt-overlay", &url("https://github.com/"), "http", None),None);}