Skip to content

iri and iri-reference reject Unicode space characters that RFC 3987 allows (U+00A0, U+2028, U+3000) #1396

Backlog

Description

@stevehu

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.

Follow-up from the review of #1395.

Activity

  1. ravismash commented on Dec 4, 2026

    @ravismash
    Contributor

    I'll take this. Fix and tests are ready; PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions