Skip to content

Unterminated double-quoted value at end of input is silently dropped #610

Description

@GrahamCampbell

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions