[BUG] range.bnf incomplete regarding whitespace and "spermies"
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript
- Área
- tooling
Línea de trabajo
Compare range.bnf with the parser behavior covered by test/fixtures/range-parse.js, using the linked reproduction cases as the starting point. Review the documented range grammar and determine whether the intended resolution is to change the grammar, restrict parsing, or document the broader accepted syntax; done means the chosen behavior is specified and covered consistently.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What / Why
There are some discrepancies between what ranges are valid according to the BNF definition and the implementation.
As far as I'm aware, this implementation (or the BNF) is the "canonical" definition for NPM version ranges.
Every range abiding by the BNF is valid according to the implementation, but the implementation also accepts ranges as valid that are not in the BNF.
Where
- Current implementation (master branch - e79ac3a)
- BNF definition in docs: https://docs.npmjs.com/cli/v6/using-npm/semver#range-grammar
- BNF definition in repo: https://github.com/npm/node-semver/blob/master/range.bnf
How
Current Behavior
Implementation allows for whitespace within a "simple" range expression at the start of a "partial", but this does not abide by the BNF grammar.
Steps to Reproduce
Using latest release:
const semver = require('semver')
console.log(semver.validRange('>= 1.2.3 < 1.6.0', {loose: false} )) // >=1.2.3 <1.6.0
console.log(semver.validRange('^ 1.2.3 || ^ 2.4.6', {loose: false})) // >=1.2.3 <1.6.0
And tests involving
https://github.com/npm/node-semver/blob/e79ac3a450e8bb504e78b8159e3efc70895699b8/test/fixtures/range-parse.js#L28-L34
and
https://github.com/npm/node-semver/blob/e79ac3a450e8bb504e78b8159e3efc70895699b8/test/fixtures/range-parse.js#L57-L60
pass, but are not valid according to the BNF.
In particular, there is no whitespace defined between comparison operators and the number:
https://github.com/npm/node-semver/blob/e79ac3a450e8bb504e78b8159e3efc70895699b8/range.bnf#L6-L9
and the tilde definition does not allow for >:
https://github.com/npm/node-semver/blob/e79ac3a450e8bb504e78b8159e3efc70895699b8/range.bnf#L10
Expected Behavior
Either:
-
The BNF definition is expanded to allow whitespace between
-
The implementation is restricted to match the BNF (e.g. only accept the ranges as valid when "loose"?)
(this obviously has backwards compatibility issues)
-
Document clearly that the implementation can parse and accept ranges outside of those defined in the BNF. (Though, perhaps will only ever return canonical ranges that comply with the BNF?)
If updating the grammar, the following change to be sufficient:
partial ::= ( ' ' )* xr ( '.' xr ( '.' xr qualifier ? )? )?
...
tilde ::= '~' ('>')? partial
Though the range definition could probably also be updated to reflect how multiple spaces are allowed:
range ::= hyphen | simple ( ( ' ' )+ simple ) * | ''
- Lenguaje dominante
- JavaScript
- Estrellas
- 5.5k
- Forks
- 624
- Merge medio
- 6 d 1 h
- PR fusionados (30 d)
- 13
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de npm/node-semver
-
[BUG] minVersion returns 0.0.0 when a 0.0.0 prerelease is the true minimumPosiblemente ocupada @thisisshivamtiwari la tomó hace 8 días. AbiertoBug Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
npm/node-semver#934 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG] new Range(comparator).test() throws TypeError for a prerelease versionPosiblemente ocupada @Boulea7 la tomó hace 35 días. AbiertoBug Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
npm/node-semver#908 ·
Los mantenedores suelen responder en 1 día
-
semver:major
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
npm/node-semver#108 · 6 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG] intersects() still returns true for an empty range against "*" (follow-up to #521)Posiblemente ocupada @json-open-source la tomó hace 35 días. AbiertoBug Needs Triage
Dificultad 3/5 1-2 días Aptitud para principiantes 64/100
npm/node-semver#909 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[BUG] `* || 1.2.3-alpha` won't match `1.2.3-alpha` (when includePrerelease = false)Posiblemente ocupada @x0Lazarus la tomó hace 41 días. AbiertoBug Needs Triage
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
npm/node-semver#906 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de npm/node-semver
Issues similares
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 87/100
OWASP/CheatSheetSeries#2905 ·
Los mantenedores suelen responder en 1 día
-
[P2] PCアプリにバージョンと更新情報の表示がないAbiertodesktop enhancement P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
AllTheMods/ATM10-Aeronautics#159 ·
Los mantenedores suelen responder en 6 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
ComposioHQ/composio#5249 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
zilliztech/memsearch#838 ·
Los mantenedores suelen responder en 1 día