fix: strip inline comments after empty unquoted values#3
Closed
kamransiddiqui wants to merge 1 commit into
Closed
Conversation
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 theskumar#600.
Change
_equal_signinsrc/dotenv/parser.pyfrommake_regex(r'(=[^%5C%5CS%5Cr%5Cn]*)')tomake_regex(r'(=)')so whitespace after=is not consumed by the regex. Inparse_unquoted_value, changere.sub(r'%5Cs+#.*', '', part).rstrip()tore.sub(r'%5Cs+#.*', '', part).strip()to remove leading whitespace that now remains part of the raw value. Together these prevent inline comments from being included as the value when a key has an empty unquoted value followed by whitespace and a comment, such asa= #cora= %5Ct #c.fe754f9ba7e4Iterate
View this request in gitgot to access the live sandbox shell, review the agent's prompt, and request revisions:
431b5049-a65a-485f-9265-1ba7f5a34004
Draft PR opened by gitgot. Mark ready for review once you've verified the change.
Verification: ✅ Passed — gitgot ran the repo’s lint/typecheck/build/test in a sandbox; this PR introduces no new failures vs the base branch (any remaining red was already failing on the base).
Issue match: ✅ Addresses the issue (95% confidence) — The diff modifies
src/dotenv/parser.pyso the_equal_signregex no longer consumes whitespace after=, leaving spaces/tabs before a#inside the_unquoted_valuecapture where the existingre.sub(r'\s+#.*', ...)can strip them; it also changesrstrip()tostrip()to discard that leading whitespace, and adds tests verifying thata= #canda= \t #cparse to an empty value.