url: pathToFileURL duplicates root slash across platforms and misses empty extended UNC servername
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 72/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- javascript, node.js
Direção de pesquisa
Comece em lib/internal/url.js, nos dois locais identificados na issue, e depois leia a lógica de pathToFileURL() ao redor e os testes de URL relacionados. Reproduza os casos de barra raiz com { windows: false } e { windows: true } e verifique como os testes existentes cobrem nomes de servidor UNC estendidos vazios. O trabalho estará concluído quando as URLs multiplataforma tiverem uma única barra no final e o nome de servidor vazio lançar ERR_INVALID_ARG_VALUE.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Version
v22.16.0 (also reproduces on main)
Platform
Microsoft Windows NT 10.0.26100.0 x64 (and POSIX platforms when passing `{ windows: true }`)
Subsystem
url
What steps will reproduce the bug?
url.pathToFileURL() has two bugs in lib/internal/url.js:
-
Cross-platform root path trailing slash duplication (
resolved[resolved.length - 1] !== path.sep):
When restoring trailing slashes stripped bypath.resolve(),pathToFileURL()compares the last character ofresolvedagainst the host platform'spath.sepinstead of the target separator (windows ? '\\' : '/'):// On Windows (where path.sep === '\\'): console.log(url.pathToFileURL('/', { windows: false }).href); // Prints: 'file:////' (4 slashes instead of 'file:///') // On POSIX / Linux / macOS (where path.sep === '/'): console.log(url.pathToFileURL('C:\\', { windows: true }).href); // Prints: 'file:///C://' (double trailing slash instead of 'file:///C:/') -
Extended UNC path empty servername bypass (
hostnameEndIndex === 2):
For extended UNC paths (\\?\UNC\...),prefixLengthis8, but the empty servername check hardcodesif (hostnameEndIndex === 2)instead ofif (hostnameEndIndex === prefixLength):console.log(url.pathToFileURL('\\\\?\\UNC\\\\share', { windows: true }).href); // Prints: 'file:///share' instead of throwing ERR_INVALID_ARG_VALUE ('Empty UNC servername')
How often does it reproduce? Is there a required condition?
Always (100% reproducible).
What is the expected behavior? Why is that the expected behavior?
url.pathToFileURL('/', { windows: false }).hrefshould return'file:///'on all platforms (including Windows).url.pathToFileURL('C:\\', { windows: true }).hrefandurl.pathToFileURL('C:/', { windows: true }).hrefshould return'file:///C:/'on all platforms (including POSIX).url.pathToFileURL('\\\\?\\UNC\\\\share', { windows: true })should throwERR_INVALID_ARG_VALUE(Empty UNC servername), matchingurl.pathToFileURL('\\\\\\share', { windows: true }).
What do you see instead?
url.pathToFileURL('/', { windows: false }).hrefon Windows returns'file:////'.url.pathToFileURL('C:\\', { windows: true }).hrefon POSIX returns'file:///C://'.url.pathToFileURL('\\\\?\\UNC\\\\share', { windows: true }).hrefreturns'file:///share'.
Additional information
In lib/internal/url.js:
- Line 1707 checks
if (hostnameEndIndex === 2)instead ofif (hostnameEndIndex === prefixLength). - Line 1722 checks
resolved[resolved.length - 1] !== path.sepinstead ofresolved[resolved.length - 1] !== (windows ? '\\' : '/').
- 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
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
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á 33 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á 34 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á 20 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
Todas as issues de nodejs/node
Issues semelhantes
-
step.duration reflects only the last retry attempt (HelperStep.run() overwrites startTime)Talvez já em andamento @mirao assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
codeceptjs/CodeceptJS#5774 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
Status: Unconfirmed
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
AllTheMods/ATM10-Aeronautics#151 ·
Mantenedores costumam responder em até 4 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
feimacode/open-design-agent-kit#66 ·
Mantenedores costumam responder em até 1 dia