Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html),
with the exception that 0.x versions can break between minor versions.

## [Unreleased]
### Changed
- Non-breaking space (U+00A0) is no longer included as part of e-mail and URL
links. It is now treated as a separator, like other whitespace (#66)

## [0.11.0] - 2026-04-12
### Changed
- Include delimiters before slashes in URLs. E.g. in `https://test.com/!/`,
Expand Down
4 changes: 3 additions & 1 deletion src/domains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ pub(crate) fn find_authority_end(
let can_be_last = match c {
// ALPHA
'a'..='z' | 'A'..='Z' | '\u{80}'..=char::MAX => {
if !iri_parsing_enabled && c > '\u{80}' {
// Non-breaking space (U+00A0) is whitespace and must end the
// authority, even though it falls in the non-ASCII range. (#66)
if (!iri_parsing_enabled && c > '\u{80}') || c == '\u{A0}' {
break;
}
// Can start or end a domain label, but not numeric
Expand Down
2 changes: 1 addition & 1 deletion src/email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl EmailScanner {
| '|'
| '}'
| '~' => true,
_ => c >= '\u{80}',
_ => c >= '\u{80}' && c != '\u{A0}',
}
}
}
2 changes: 1 addition & 1 deletion src/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ fn find_url_end(s: &str, quote: Option<char>, iri_parsing_enabled: bool) -> Opti

for (i, c) in s.char_indices() {
let can_be_last = match c {
'\u{00}'..='\u{1F}' | ' ' | '|' | '\"' | '<' | '>' | '`' | '\u{7F}'..='\u{9F}' => {
'\u{00}'..='\u{1F}' | ' ' | '|' | '\"' | '<' | '>' | '`' | '\u{7F}'..='\u{9F}' | '\u{A0}' => {
// These can never be part of an URL, so stop now. See RFC 3986 and RFC 3987.
// Some characters are not in the above list, even they are not in "unreserved"
// or "reserved":
Expand Down
10 changes: 10 additions & 0 deletions tests/email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ fn fuzz() {
assert_linked("a@a.xyϸ", "|a@a.xyϸ|");
}

#[test]
fn non_breaking_space_does_not_join_email() {
// Non-breaking space (U+00A0) must not be swallowed into an e-mail link.
// https://github.com/robinst/linkify/issues/66
assert_linked(
"this is a mail address:\u{a0}test@example.com\u{a0}surrounded by non-breaking spaces",
"this is a mail address:\u{a0}|test@example.com|\u{a0}surrounded by non-breaking spaces",
);
}

fn assert_not_linked(s: &str) {
let mut finder = LinkFinder::new();
finder.kinds(&[LinkKind::Email]);
Expand Down
10 changes: 10 additions & 0 deletions tests/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,16 @@ fn fuzz() {
assert_not_linked("ab:/ϸ");
}

#[test]
fn non_breaking_space_does_not_join_url() {
// Non-breaking space (U+00A0) must not be part of a URL.
// https://github.com/robinst/linkify/issues/66
assert_linked(
"see https://example.com\u{a0}now",
"see |https://example.com|\u{a0}now",
);
}

fn assert_not_linked(s: &str) {
assert_linked(s, s);
}
Expand Down