From ed31eafd91007c2ed382f63f1e13b7b820c2bcaa Mon Sep 17 00:00:00 2001 From: rgxdev Date: Tue, 24 Nov 2026 01:51:10 +0100 Subject: [PATCH 1/2] fix(command): search a single non-ASCII word instead of opening it as a punycode host Signed-off-by: rgxdev --- CHANGELOG.md | 2 ++ crates/browser-core/src/command.rs | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b369be63..e7100a1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -115,6 +115,8 @@ All notable changes to Tarn are documented in this file. The format is based on ### Fixed +- A single word with non-ASCII letters, such as `übersetzer`, is searched for instead of opened as + a site named `xn--bersetzer-p9a`. - Retry and Reload now work on a tab whose first page never loaded (for example a router's page that fails under Strict's HTTPS-only rule); they did nothing and left a blank page, also after the site was set to Standard. diff --git a/crates/browser-core/src/command.rs b/crates/browser-core/src/command.rs index b12f0f9d..8f345a01 100644 --- a/crates/browser-core/src/command.rs +++ b/crates/browser-core/src/command.rs @@ -208,10 +208,9 @@ fn host_like(input: &str) -> Option { if host == "localhost" || host.ends_with(".localhost") || bare.parse::().is_ok() { return Some(local); } - let tld = host.rsplit('.').next()?; - let has_tld = host.contains('.') && tld.len() >= 2 && tld.chars().all(|c| c.is_ascii_alphabetic()); - let punycode_tld = tld.starts_with("xn--"); - (has_tld || punycode_tld).then(|| Url::parse(&format!("https://{input}")).ok())? + let (_, tld) = host.rsplit_once('.')?; + let has_tld = (tld.len() >= 2 && tld.chars().all(|c| c.is_ascii_alphabetic())) || tld.starts_with("xn--"); + has_tld.then(|| Url::parse(&format!("https://{input}")).ok())? } pub const GLYPHS: &[(&str, &str)] = &[ @@ -605,6 +604,7 @@ mod tests { assert_eq!(nav("app.localhost:5173"), "http://app.localhost:5173/"); assert_eq!(nav("example.com:8443/x"), "https://example.com:8443/x"); assert_eq!(nav("münchen.de"), "https://xn--mnchen-3ya.de/"); + assert_eq!(nav("пример.рф"), "https://xn--e1afmkfd.xn--p1ai/"); assert_eq!(nav("about:blank"), "about:blank"); } @@ -629,6 +629,8 @@ mod tests { assert!(matches!(kind("rust lifetimes"), Some(Input::Search(_)))); assert!(matches!(kind("re:invent"), Some(Input::Search(_)))); assert!(matches!(kind("hello"), Some(Input::Search(_)))); + assert!(matches!(kind("übersetzer"), Some(Input::Search(_)))); + assert!(matches!(kind("xn--bersetzer-p9a"), Some(Input::Search(_)))); assert!(matches!(kind("what is a.b"), Some(Input::Search(_)))); assert!(matches!(kind("mailto:a@example.com"), Some(Input::External(_)))); assert_eq!(kind(" "), None); From 915abf458e22aeefc1a7c1bf6cc4e0fcf58d2953 Mon Sep 17 00:00:00 2001 From: rgxdev Date: Tue, 24 Nov 2026 01:59:08 +0100 Subject: [PATCH 2/2] test(command): dotless hosts with a port or path are searched, IDN or not Signed-off-by: rgxdev --- crates/browser-core/src/command.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/browser-core/src/command.rs b/crates/browser-core/src/command.rs index 8f345a01..b38cf5b5 100644 --- a/crates/browser-core/src/command.rs +++ b/crates/browser-core/src/command.rs @@ -631,6 +631,9 @@ mod tests { assert!(matches!(kind("hello"), Some(Input::Search(_)))); assert!(matches!(kind("übersetzer"), Some(Input::Search(_)))); assert!(matches!(kind("xn--bersetzer-p9a"), Some(Input::Search(_)))); + for s in ["intranet:3000/x", "übersetzer:3000/x", "xn--bersetzer-p9a:3000/x"] { + assert!(matches!(kind(s), Some(Input::Search(_))), "{s}"); + } assert!(matches!(kind("what is a.b"), Some(Input::Search(_)))); assert!(matches!(kind("mailto:a@example.com"), Some(Input::External(_)))); assert_eq!(kind(" "), None);