Skip to content

Restore support for usernames containing '@' in connection strings. #418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

natano
Copy link

@natano natano commented Mar 19, 2019

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

elprans commented Mar 19, 2019

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: #418
Fixes: #471
@elprans elprans closed this in 5513b9d Oct 3, 2019
@elprans elprans closed this in #472 Oct 3, 2019
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.

2 participants