Skip to content

Conversation

@natano
Copy link

Prior to version 0.18.0 it was possible to have an '@' in a connection
string, but that feature got lost when the parsing code was rewritten to
support multiple host addresses.

Prior to version 0.18.0 it was possible to have an '@' in a connection string, but that feature got lost when the parsing code was rewritten to support multiple host addresses.
@elprans
Copy link
Member

If I'm reading libpq's parsing code correctly, it looks for the first @ when splitting [1], which is inconsistent with what urlparse does. I think we should fix that discrepancy instead and require urlescape on usernames containing the @ character.

[1] https://github.com/postgres/postgres/blob/28988a84cf19c01dba3c3fb40e95d9cd6e4888da/src/interfaces/libpq/fe-connect.c#L5575-L5581

elprans added a commit that referenced this pull request Aug 19, 2019
When a connection string component contains characters that have a special meaning in the URI (e.g. '@' or '='), percent-encoding must be used. asyncpg must take care to unquote the parsed components correctly, and it doesn't currently. Additionally, this makes asyncpg follow the libpq's behavior of parsing the authentication part of netloc, i.e. split on the first '@' and not the last. Fixes: #418Fixes: #471
Sign up for freeto 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.

2 participants

@natano@elprans