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). |
This comment was marked as resolved.
This comment was marked as resolved.
|
Understood, thank you for the reminder and context @MikeMcC399! I will hold off on opening any new PRs in Node.js until these are reviewed and landed. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67132 +/- ##
==========================================
+ Coverage 90.66% 90.68% +0.01%
==========================================
Files 797 797
Lines 278791 278794 +3
Branches 53620 53616 -4
==========================================
+ Hits 252768 252820 +52
+ Misses 16376 16339 -37
+ Partials 9647 9635 -12
🚀 New features to boost your workflow:
|
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.