Skip to content

Handle CRLF invalid lines in parser recovery#669

Open
CodingFeng101 wants to merge 1 commit into
theskumar:mainfrom
CodingFeng101:codex/preserve-cr-newline
Open

Handle CRLF invalid lines in parser recovery#669
CodingFeng101 wants to merge 1 commit into
theskumar:mainfrom
CodingFeng101:codex/preserve-cr-newline

Conversation

@CodingFeng101

Copy link
Copy Markdown

What changed

This updates the parser recovery regex for invalid lines so CRLF is consumed as one newline sequence, matching the parser's other newline handling.

Why

When an invalid .env line used CRLF line endings, _rest_of_line matched \r before \r\n. That left the \n behind for the next parse iteration, so recovery could produce an extra blank binding before the following valid line.

Validation

  • PYTHONPATH=src python -m pytest tests\test_parser.py::test_parse_stream -q
  • PYTHONPATH=src python -m pytest tests\test_parser.py -q
  • python -m ruff check src\dotenv\parser.py tests\test_parser.py
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant