Repository navigation
dotenv: strip leading UTF-8 BOM in parseEnv and --env-file - #67132
helmipradita wants to merge 1 commit into
Conversation
|
Review requested:
|
|
Welcome to Node.js, and thank you for your first contribution! Before review, please take a moment to read:
Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal. Caution AgentScan found account activity patterns that may be consistent with automation. This is a heuristic, not proof that this pull request was opened by an agent or violates policy. AI-assisted contributions are permitted, but automated tooling must not open pull requests without advance approval, and contributors must personally understand, test, verify, and take responsibility for every submitted change. See the AgentScan analysis, AI use policy, and automation policy for additional context. |
Fixes: nodejs#67102 Files starting with a UTF-8 Byte Order Mark (\xEF\xBB\xBF) are common on Windows. Previously, Dotenv::ParseContent did not strip a leading BOM, leaving it attached to the first key and corrupting process.env access. Strip a leading UTF-8 BOM if present at the beginning of content and add a test case in test-util-parse-env.js. Signed-off-by: Helmi Pradita <50313181+helmipradita@users.noreply.github.com>
2916cb7 to
650b51a
Compare
|
Regarding the AgentScan flag: this PR is personally authored and manually prepared following issue #67102. The commit message and metadata have also been updated to strictly comply with Node.js guidelines (valid subsystem, line length <= 72, and Signed-off-by trailer). |
|
The recommendations in: advise you should tackle only one issue at a time and that you should not open any new PRs until your first PR has been approved. You already have an unapproved PR #67111 open at this time. Until the first PR has been approved and has landed in the Waiting until the first PR has landed ensures that you as a contributor have experienced the complete process from PR submission to successful landing. After this has been completed, any new PRs or new commits to an existing PR are treated to rules for regular Contributors. GitHub Actions CI workflows are then run automatically without intervention by a team member. |
Fixes #67102
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesDescription of change
Files beginning with a UTF-8 Byte Order Mark (
\xEF\xBB\xBF) are common on Windows (such as those generated by PowerShell 5.1Set-Content -Encoding utf8or Notepad's "UTF-8 with BOM").Previously,
Dotenv::ParseContentinsrc/node_dotenv.ccremoved\rcharacters but did not strip a leading UTF-8 BOM, resulting in the BOM remaining attached to the first key (e.g.\uFEFFAinstead ofA). Consequently, the first environment variable was inaccessible via its expected name underprocess.env.This PR strips a leading UTF-8 BOM (
\xEF\xBB\xBF) fromcontentif present at index 0 and adds a test asserting thatutil.parseEnvcorrectly strips the leading BOM.