diff --git a/crates/xfa/src/pdf.rs b/crates/xfa/src/pdf.rs index 833fae875..61b287e3d 100644 --- a/crates/xfa/src/pdf.rs +++ b/crates/xfa/src/pdf.rs @@ -779,10 +779,11 @@ fn link_target(href: &str) -> Option<&str> { ok.then_some(href) } -/// Whether `after` (a web address past its `//`) names a host: what comes before the path, query -/// or fragment, past any user name and before any port, isn't empty. +/// Whether `after` (a web address past its `//`) names a host: what comes before the path (which a +/// backslash starts too, as web addresses read it), query or fragment, past any user name and +/// before any port, isn't empty. fn has_host(after: &str) -> bool { - let authority = after.split(['/', '?', '#']).next().unwrap_or_default(); + let authority = after.split(['/', '\\', '?', '#']).next().unwrap_or_default(); let host = authority.rsplit('@').next().unwrap_or_default(); // An IPv6 host is bracketed and holds colons of its own. let host = if host.starts_with('[') { host } else { host.split(':').next().unwrap_or_default() }; diff --git a/crates/xfa/src/tests.rs b/crates/xfa/src/tests.rs index e4a0c410d..9901903bc 100644 --- a/crates/xfa/src/tests.rs +++ b/crates/xfa/src/tests.rs @@ -511,7 +511,7 @@ fn a_rule_between_two_pieces_of_a_link_keeps_them_apart() { fn links_to_anything_but_web_and_email_addresses_stay_plain_text() { let long = format!("https://example.com/{}", "a".repeat(2100)); let body = format!( - r#"one two three four five six seven eight nine ten"# + r#"one two three four five six seven eight nine nine and a half ten"# ); let mut doc = Document::open(Arc::new(shell(&rich_draw_form("7in", &body)))).unwrap(); let report = render_into(&mut doc).unwrap();