Repository navigation
Conversation
The guard in parseName() required the raw name to be strictly longer
than 8 characters before stripping the leading "export " prefix. A
single-character variable name ("export A") is exactly 8 characters,
so the prefix was never stripped and the entry failed with
InvalidFileException, rejecting the whole file. Two-character names
and longer were unaffected.
Relax the guard to >= 8 and cover the boundary with tests for both
space and tab separators.
Collaborator
|
Thanks for the report and the fix! I went with a slightly different approach in #599, dropping the length check altogether rather than adjusting it, since the prefix and whitespace checks already cover it. That's merged now and will go out in 5.6.5. Closing this in favour of that, but much appreciated for tracking it down. |
Author
|
Dropping the guard entirely is cleaner indeed, the prefix and whitespace checks already imply a valid length. Thanks for the quick turnaround! |
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 dotenv file containing an export line with a single-character variable name fails to parse:
Since the exception is thrown at file level, one such line rejects the entire file.
export AB=1and longer names work fine.The cause is the guard in
EntryParser::parseName():export Ais exactly 8 characters, so the strict> 8comparison skips the prefix stripping and the raw stringexport Ais then rejected as an invalid name.This PR relaxes the guard to
>= 8and adds regression tests for both space and tab separators. The other conditions are unchanged, so inputs likeexportFOO=...(no whitespace after the prefix) or a variable actually namedexportare unaffected.Full test suite passes: 252 tests, 518 assertions.