Unterminated double-quoted value at end of input is silently dropped
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start at Lines::process() for input passed to Dotenv::parse(); compare end-of-input handling with the single-quoted path and the transducer's existing missing-closing-quote behavior. Done means unterminated double-quoted input raises that error, does not swallow later lines, and properly closed multiline values remain unchanged.
Written by the indexing model from the issue text.
Description
When a double-quoted value is left unterminated at the end of the input, the whole entry and every line after it are dropped with no error. This is inconsistent with the single-quoted case, which reports a missing closing quote, so a stray quote can silently erase configuration rather than failing loudly.
Dotenv::parse('FOO="bar'); // returns [] — no exception
Dotenv::parse("A=\"oops\nB=keep"); // returns [] — B is swallowed too
Dotenv::parse("FOO='bar"); // correctly throws "a missing closing quote"
The cause is in Lines::process(): when the input ends while still inside a multiline value, the buffered content is discarded instead of being handed to the parser. Emitting the still-open buffer sends it to the transducer, which then reports the same "missing closing quote" error the single-quoted path already produces, and stops swallowing the following lines. A properly closed multiline value is unaffected.
This is a behaviour change rather than a pure bugfix, since input that currently returns an empty or partial array would start throwing. The current behaviour is silent data loss so the fix is well justified, but under SemVer it belongs in the next major rather than a 5.x release.
- Dominant language
- PHP
- Stars
- 13.6k
- Forks
- 664
- Avg merge
- 11h 2m
- Merged PRs (30d)
- 15
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vlucas/phpdotenv
All issues in vlucas/phpdotenv
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·