-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] range.bnf incomplete regarding whitespace and "spermies" #392
Comments
How would you like to proceed? |
Just bumping here. This is relevant to other projects that make use of NPM-style version ranges or must parse Shouldn't we want a parser that implements the If one is to interpret the |
@gnattishness I guess one way to interpret this is that the grammar is not a spec but only a nice but incomplete documentation artifact and rather that only the actual implemented JS code here is the "spec"? |
@isaacs you wrote this grammar, so what's your take on this? |
@pombredanne Agreed, the code appears more a "reference implementation" that the BNF was made to reflect. Though it could also be that (as in 3) the BNF defines a "canonical representation" that |
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
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:
And tests involving
node-semver/test/fixtures/range-parse.js
Lines 28 to 34 in e79ac3a
and
node-semver/test/fixtures/range-parse.js
Lines 57 to 60 in e79ac3a
pass, but are not valid according to the BNF.
In particular, there is no whitespace defined between comparison operators and the number:
node-semver/range.bnf
Lines 6 to 9 in e79ac3a
and the tilde definition does not allow for
>
:node-semver/range.bnf
Line 10 in e79ac3a
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:
Though the
range
definition could probably also be updated to reflect how multiple spaces are allowed:The text was updated successfully, but these errors were encountered: