Repository navigation
Disable interpolation when reading the connection service file - #1395
Open
spicysharkco wants to merge 1 commit into
Open
spicysharkco wants to merge 1 commit into
spicysharkco wants to merge 1 commit into
Conversation
ConfigParser treated "%" in service file values as interpolation syntax, so a password such as "pa%ss" raised InterpolationSyntaxError when the service was selected. libpq reads the values literally.
This branch has not been deployed
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.
A connection service file value that contains
%makesconnect()fail withconfigparser.InterpolationSyntaxError, for examplepassword=pa%ssor a host or option value with a%in it. The error only appears once that service is selected, because the values are read lazily.The service file is parsed with a default
ConfigParser, which appliesBasicInterpolationto every value. libpq has no such step: it takes the text after=as it is. The change creates the parser withinterpolation=None, so values are used literally. A value written as%%to work around the error now reads as two percent signs, as it does in libpq.Tested by changing the password in the
test_service_databasesection oftest_connect_connection_service_filetotest%password. Without the change that test errors with'%' must be followed by '%' or '(', found: '%password'. With it,TestConnectParamspasses (11 tests), and flake8 and mypy are clean.#1376 re-indents the service file block in
connect_utils.py, including this line, so whichever lands second needs a trivial rebase.