-
Notifications
You must be signed in to change notification settings - Fork 35
Description
When I try to specify the postgresql iri as pq://[::1]:5432/database the connection fails.
This URL is explicitly allowed and stated that it is correct in this comment: https://github.com/python-postgres/fe/blob/master/postgresql/iri.py#L13
The reason why this happens is broken parsing here:
Line 49 in 23f5927
| cpd['host'] = host[1:-1] |
This results in
: being used as a host, which is not valid. When a host is detected, that is enclosed in square brackets, the square brackes are removed and it is either parsed as unix domain socket:
pq://[unix::var:run:postgresql]/database (probably, I didn't find any documentation for that syntax)
Or, alternatively we just remove the first and last char again. This is wrong.
As a "workaround" one can (currently) specify ipv6-literal addresses like this:
pq://[_::1_]/database
Where the underscore is arbitrary (apart from ]/ and other url-special-characters).
I believe the correct fix would be to just remove the else branch (as I don't understand which URLs that might be needed for) and add a test case, so IPv6 literals are not broken accidentally anymore.