Skip to content

parseEnvFile() should be improved to avoid false positives when parsing .env files #5

@blancks

Description

@blancks

Current Behavior:
The parseEnvFile() function currently checks if a line starts with # using str_starts_with($line, '#'). If the line contains leading whitespace before the #, such as in lines like # something like = this, this check fails and the line is not treated as a comment, potentially leading to incorrect parsing.

Expected Behavior:
The function should trim leading whitespace (ltrim) from each line before checking if it starts with #. This will ensure that lines with spaces or tabs before the # are correctly identified as comments and ignored by the parser.

Additional Context:
This adjustment will improve compatibility with .env files where users may add spaces before comments, preventing unexpected false positives and parsing errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions