Enhance .env parsing for inline comments with leading whitespace#1029
Open
udithavithanage wants to merge 1 commit into
Open
Enhance .env parsing for inline comments with leading whitespace#1029udithavithanage wants to merge 1 commit into
udithavithanage wants to merge 1 commit into
Conversation
…hitespace in .env files
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.
This pull request improves the parsing of inline comments in environment variable files, especially around handling the
#character in values. The main change is to correctly distinguish between#as part of a value and#as the start of a comment, depending on whether it is preceded by whitespace. This is reflected in both the parser logic and expanded test coverage.Parsing improvements
LINEregular expression inlib/main.jsto treat#as the start of a comment only when it is preceded by whitespace.#to be included as part of an environment variable value when it is not preceded by whitespace.Examples
DB_PASS=test*&#secret123test*&#secret123DB_PASS=test #secret123testDB_PASS="test #secret123"test #secret123Test coverage enhancements
tests/.env,tests/.env.multiline, and corresponding assertions intests/test-parse.jsandtests/test-parse-multiline.js.#characters embedded in unquoted values.#characters inside quoted values.#is and is not preceded by whitespace.These tests verify that comments are parsed correctly while preserving
#characters that are intended to be part of the value.Fixes: #1018