You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
iri and iri-reference reject Unicode space characters that RFC 3987 allows (U+00A0, U+2028, U+3000) #1396
iri and iri-reference reject Unicode space characters that RFC 3987 allows in an IRI. U+00A0, U+2028 and U+3000, for example, are all ucschar (U+00A0 to U+D7FF in the ABNF), but these values are invalid:
http://x/a b
http://x/a b
http://x/a b
The same happens with a space character in the host, e.g. http://a b/.
Cause:AbstractRFC3986Format.matches parses the value with java.net.URI, which refuses any character for which Character.isSpaceChar is true. handleException doesn't recover these values, so they fail before the RFC 3987 character checks run. This was already the behavior before #1395. Since #1395, though, the AbstractRFC3987Format Javadoc says it allows the non-ASCII characters RFC 3987 allows, which isn't true for these.
Possible fix: for internationalized formats, percent-encode non-ASCII characters before calling new URI(...), and keep running the RFC 3987 character checks (containsNonIriCharacter, containsBidiFormatting) on the raw value. This changes the URI that validate(URI) and validateIri(URI) receive, so subclasses could see a difference, and it needs a CHANGELOG entry. Check the authority too: a percent-encoded reg-name is valid under RFC 3986, but the current authority check may handle it differently.
Tests to add: the three values above should be valid as iri and iri-reference. A C1 control such as http://x/a\u0085b, which is not ucschar, should stay invalid. The uri and uri-reference results should not change.
Activity
ravismash commentedon Dec 4, 2026
I'll take this. Fix and tests are ready; PR shortly.