Skip to content

Reject first-segment colons when validating relative URI paths - #160

Open
ac1982 wants to merge 1 commit into
python-hyper:mainfrom
ac1982:fix/relative-path-colon
Open

ac1982 wants to merge 1 commit into
python-hyper:mainfrom
ac1982:fix/relative-path-colon

Conversation

@ac1982

@ac1982 ac1982 commented Oct 8, 2026

Copy link
Copy Markdown

Fixes #91's validation case.

uri_reference('.://').is_valid() currently returns True, and Validator().check_validity_of('path') accepts the same invalid relative reference. RFC 3986 §4.2 forbids a colon in the first path segment of a reference without a scheme.

Apply that contextual rule in both the configured validator and the legacy URI validation methods. Parsing remains permissive, consistent with the existing separation of parsing and validation. Standalone path_is_valid() keeps its component-only behavior, since a colon is valid in a rootless path when a scheme is present. Legal references such as urn:a:b, ./a:b, /a:b, and percent-encoded colons remain valid.

Validation on Linux / Python 3.12:

  • The new tests fail on the base: 5 failed, 11 passed.
  • Full suite: 2,930 passed, with 100% coverage (16 new cases).
  • All pre-commit checks, HTML documentation build, 57 doctests, and wheel/sdist builds passed.
  • Project typing-coverage check: 76.87%, above the required 75%.

This branch is based directly on main and is independent of #159.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

":" in relative path within relative reference

1 participant