[EnvConfigurator] Do not escape literal values in env files#1095
Open
DjLeChuck wants to merge 1 commit into
Open
[EnvConfigurator] Do not escape literal values in env files#1095DjLeChuck wants to merge 1 commit into
DjLeChuck wants to merge 1 commit into
Conversation
Author
|
Should I fix Fabbot issues about code style? |
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.
Closes #1096
Problem
When a recipe defines a value wrapped in single quotes - for example to store a JSON array:
{ "dotenv": { "dev": { "ALLOWED_LANGUAGES": "'[\"en\",\"de\",\"es\"]'" } } }The configurator incorrectly wrapped the value in double quotes and escaped the inner double quotes, producing:
ALLOWED_LANGUAGES="'[\"en\",\"de\",\"es\"]'"Instead of the expected single-quoted dotenv literal:
ALLOWED_LANGUAGES='["en","de","es"]'The dotenv format treats single-quoted values as fully literal strings (no escape processing), which makes them the natural fit for JSON content.
Solution
Skip the double-quote wrapping when the value already starts and ends with a single quote. Any other value continues through the existing escaping path introduced in #200.
Tests
Added a
ALLOWED_LANGUAGES='["en","de","es"]'fixture to both EnvConfiguratorTest andDotenvConfiguratorTest to cover this case, alongside the existing assertions for values that require double-quote escaping.