util.parseEnv and --env-file keep a leading UTF-8 BOM in the first key
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 78/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- javascript
- Domínio
- backend
Direção de pesquisa
Comece lendo src/node_dotenv.cc, especialmente Dotenv::ParseContent na linha citada na issue. Verifique os testes existentes sobre o comportamento de --env-file e util.parseEnv com uma entrada que começa com um BOM UTF-8. O trabalho estará concluído quando ambos os pontos de entrada analisarem a primeira chave sem o BOM e preservarem os valores esperados.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- JavaScript
- Estrelas
- 123k
- Forks
- 39.3k
- Merge médio
- 4d 12h
- PRs com merge (30d)
- 240
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de nodejs/node
-
node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`Talvez já em andamento @lazerg assumiu há 24 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
nodejs/node#66551 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already existTalvez já em andamento @Sepandard assumiu há 34 dias. Abertadoc
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
Mantenedores costumam responder em até 1 dia
-
Stream.prototype.forEach will block in first promise in queue before read more chunkTalvez já em andamento @mmustafasenoglu assumiu há 35 dias. Abertadoc
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
Mantenedores costumam responder em até 1 dia
-
nodejs 26.8.2 fails to build with clang/LLVMTalvez livre de novo @btyagi18 assumiu há 21 dias e não há nenhum pull request aberto. Abertabuild
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
nodejs/node#66076 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
`TextEncoder.encodeInto()` underfills the destination for some non-ASCII textTalvez já em andamento @XadillaX assumiu há 48 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
nodejs/node#65994 · 2 comentários · 2 reações ·
Mantenedores costumam responder em até 1 dia
Todas as issues de nodejs/node
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
microsoft/monaco-editor#5563 ·
Mantenedores costumam responder em até 1 dia
-
Package downloads never retry: getUrlWithResuming's retry catch cannot see a rejected requestAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
account: profile bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 5 dias
-
ai-driven-fuzzing bug claude Minor
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
linagora/cozy-client#1777 · 1 comentário · 1 reação ·
Mantenedores costumam responder em até 1 dia