servo / rust-url

URL parser for Rust
https://docs.rs/url/
Apache License 2.0
1.27k stars 317 forks source link

InvalidPort is returned for URLs with a '#' #860

Closed adriangb closed 11 months ago

adriangb commented 11 months ago

The following Postgres DSN fails to parse: postgresql://postgres:postgres#@localhost:5432/postgres. I'm not sure if this is intended or a bug, if it's the former please go ahead and close.

valenting commented 11 months ago

According to the reference URL parser this is an invalid URL - link - The # marks the start of the fragment, so the parts before it would be the host and port. Since :posgres isn't a valid port number, the parsing fails.

For this to work, the user and password need to be percent encoded using the user-info percent encoding set