rfc3986 icon indicating copy to clipboard operation
rfc3986 copied to clipboard

uri_reference.is_valid() accepts invalid hostnames and out-of-range ports

Open QuantumNovice opened this issue 1 month ago • 0 comments

The validator returns True for inputs that violate URI rules.

Examples:

In [15]:  uri_reference('google.com/path').is_valid()
Out[15]: True
In [27]:  uri_reference('http://example.com:99999/').is_valid()
Out[27]: True

Expected behavior:

The validator should reject missing schemes when a hostname is present and should reject port values greater than 65535.

Actual behavior:

is_valid() returns True for both invalid inputs.

Steps to reproduce:

  1. Run the two example expressions in a Python REPL.
  2. Observe that both return True.

Environment:

Library version: Python version: Python 3.10.14 OS: Windows

Fix? :

  • Add port range validation and treat bare hostnames with paths as invalid
  • unless explicitly allowed by the spec.

QuantumNovice avatar Dec 03 '25 06:12 QuantumNovice