Decode percent-encoded user/password in connection_url - #451
Open
hikmetba-bit wants to merge 1 commit into
Open
hikmetba-bit wants to merge 1 commit into
hikmetba-bit wants to merge 1 commit into
Conversation
Locker#work parses the connection_url option with URI.parse, then passes uri.user/uri.password straight through to PG::Connection.open. URI#user and URI#password return the RAW percent-encoded component, so a password containing characters that require URL-escaping (e.g. 'p%40ss%3Aword' for 'p@ss:word') was handed to PG::Connection.open still escaped, causing authentication to fail. Decode both with URI.decode_www_form_component before building the connection opts, guarding against nil so a URL with no user/password still works. Fixes que-rb#436.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #436.
Locker#workparses theconnection_urloption withURI.parse, then passesuri.user/uri.passwordstraight through toPG::Connection.open.URI#userandURI#passwordreturn the raw percent-encoded component, so a password containing characters that require URL-escaping (e.g.p%40ss%3Awordforp@ss:word) was handed toPG::Connection.openstill escaped, causing authentication to fail — exactly the failure reported in the issue.Fix
Decode both
userandpasswordwithURI.decode_www_form_componentbefore building the connection opts (nil-guarded, so a URL with no credentials still works).Verification
Ran the exact parsing logic in isolation against 4 cases:
I could not run
que's full locker integration spec suite in this environment since it requires a live PostgreSQL instance to connect against — flagging that honestly. The change itself is a 2-line, narrowly-scoped fix isolated to how the two URI components are read, with no other code path affected.🤖 Generated with Claude Code