util.parseEnv and --env-file keep a leading UTF-8 BOM in the first key
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 78/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript
- Bereich
- backend
Rechercherichtung
Lies zuerst src/node_dotenv.cc, insbesondere Dotenv::ParseContent an der im Issue angegebenen Zeile. Prüfe die vorhandenen Tests zum Verhalten von --env-file und util.parseEnv bei Eingaben, die mit einem UTF-8-BOM beginnen. Das Ziel ist erreicht, wenn beide Einstiegspunkte den ersten Schlüssel ohne BOM parsen und die erwarteten Werte beibehalten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Version
v24.18.0 (the code is the same on main)
Platform
Windows 11 x64 (not platform-specific; the file bytes are what matter)
Subsystem
dotenv (--env-file, util.parseEnv)
What steps will reproduce the bug?
printf '\xef\xbb\xbfA=1\r\nB=2\r\n' > .env
node --env-file=.env -e "console.log(process.env.A, process.env.B)"
node -e "console.log(require('util').parseEnv('A=1\nB=2'))"
Such files are common on Windows: PowerShell 5.1 Set-Content -Encoding utf8 / Out-File -Encoding utf8 and Notepad's "UTF-8 with BOM" write a leading EF BB BF.
How often does it reproduce? Is there a required condition?
Always, when the file starts with a UTF-8 BOM.
What is the expected behavior? Why is that the expected behavior?
1 2 and { A: '1', B: '2' }: the BOM is an encoding marker, not part of the first key. The dotenv package returns { A: '1', B: '2' } for the same bytes, and Node already skips a BOM when loading CommonJS/ESM sources and JSON.
What do you see instead?
undefined 2
{ B: '2', 'A': '1' }
The first variable is silently lost under its real name.
Additional information
Dotenv::ParseContent (src/node_dotenv.cc:147) strips \r but not a leading BOM, so it stays in the first key. Skipping a leading \xEF\xBB\xBF at the start of the input there would fix both --env-file and util.parseEnv. This also affects tools that moved to util.parseEnv, e.g. Vite's .env loading.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 123k
- Forks
- 39.3k
- Ø Merge
- 4 T. 12 Std.
- Gemergte PRs (30 T.)
- 240
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus nodejs/node
-
node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`Evtl. vergeben @lazerg hat das vor 24 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
nodejs/node#66551 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already existEvtl. vergeben @Sepandard hat das vor 34 Tagen übernommen. Offendoc
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
Maintainer antworten meist innerhalb von 1 Tag
-
Stream.prototype.forEach will block in first promise in queue before read more chunkEvtl. vergeben @mmustafasenoglu hat das vor 35 Tagen übernommen. Offendoc
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
nodejs 26.8.2 fails to build with clang/LLVMEvtl. wieder frei @btyagi18 hat das vor 21 Tagen übernommen, und es ist kein Pull Request offen. Offenbuild
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
nodejs/node#66076 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
`TextEncoder.encodeInto()` underfills the destination for some non-ASCII textEvtl. vergeben @XadillaX hat das vor 48 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
nodejs/node#65994 · 2 Kommentare · 2 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
account: profile bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 5 Tagen
-
ai-driven-fuzzing bug claude Minor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
linagora/cozy-client#1777 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
NanmiCoder/dsh-agent-teams#326 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[guide] AGENTS.md claims the coverage gate, e2e and full lint run on every PR after ADR 0011 focused validationEvtl. vergeben @hivecommons-hive hat das heute übernommen. Offenagent/guide documentation hive/claimed-by-guide stage/040-covered-by-pr
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 81/100
cncf/endusers#2006 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag