Skip to content

Accept file:// URLs per RFC 8089 - #483

Open
itzzdev09 wants to merge 1 commit into
python-validators:masterfrom
itzzdev09:fix/url-file-scheme
Open

itzzdev09 wants to merge 1 commit into
python-validators:masterfrom
itzzdev09:fix/url-file-scheme

Conversation

@itzzdev09

@itzzdev09 itzzdev09 commented Sep 26, 2026 •

Copy link
Copy Markdown

Fixes #481.

url() rejected file:// URLs such as file:///var/www because their authority (netloc) is empty or "localhost", neither of which _validate_netloc accepts as a hostname. RFC 8089 defines both an empty and a "localhost" authority as valid for a local file URL, so this adds file to the accepted schemes and skips hostname validation for those two authorities specifically.

A file:// URL with a non-local authority (file://example.com/path) still goes through the normal hostname check, unchanged.

url() rejected file:// URLs like file:///var/www because their
authority (netloc) is empty or "localhost", neither of which
_validate_netloc accepts as a hostname. RFC 8089 defines both an
empty and a "localhost" authority as valid for a local file URL.

A file URL with a non-local authority (file://example.com/path)
still goes through the normal hostname check, unchanged.

This branch has not been deployed

No deployments
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.

Local file URL validation

1 participant