Repository navigation
Do not interpolate single-quoted values (fixes #422) - #745
Open
36taransingh5-dotcom wants to merge 4 commits into
Open
36taransingh5-dotcom wants to merge 4 commits into
36taransingh5-dotcom wants to merge 4 commits into
Conversation
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.
Problem
set_keywrites values in single quotes intending to preserve them literally, but reading them back withdotenv_values/load_dotenv(which interpolate by default) still expands variable references inside single-quoted values. The value is silently corrupted:This is the round-trip data loss reported in #422.
Root cause
parser.Bindingdiscarded the quote character beforemain.resolve_variablesran, so the resolver had no way to know a value was single-quoted.Fix
parser.parse_valuenow returns the quote character alongside the value, andBindingcarries it in a newquotefield.main.dict()uses a private_parse_full()that keeps the quote triples (the publicparse()shape is unchanged).resolve_variablesreturns single-quoted values verbatim, matching POSIX shell semantics where single quotes inhibit expansion. The literal text of a single-quoted value remains visible to later values, consistent with the existing chained-resolution behaviour: withB='${A}'thenC=${B},Cresolves to the literal text${A}.Interpolation of double-quoted and unquoted values is unchanged.
Test changes
set_keyround-trip and literal single-quote handling.({"b": "c"}, "a='${b}'", True, ...)previously expected{"a": "c"}and now expects the literal{"a": "${b}"}. This is an intentional behaviour change implementing Unable to escape posix expansion #422; flagging it explicitly for review.Fixes #422.
Developed with AI assistance.