[BUG] range.bnf incomplete regarding whitespace and "spermies"
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- javascript
- 領域
- tooling
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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 ) * | ''
- 主要言語
- JavaScript
- スター
- 5.5k
- フォーク
- 624
- 平均マージ
- 6日 1時間
- マージ済み PR(30日)
- 13
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
npm/node-semver のほかの issue
-
[BUG] minVersion returns 0.0.0 when a 0.0.0 prerelease is the true minimum対応中かも @thisisshivamtiwari が 10 日前に担当しました。 オープンBug Needs Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
npm/node-semver#934 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] new Range(comparator).test() throws TypeError for a prerelease version対応中かも @Boulea7 が 37 日前に担当しました。 オープンBug Needs Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
npm/node-semver#908 ·
メンテナーはふだん 1 日以内に返信
-
semver:major
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
npm/node-semver#108 · コメント 6 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
npm/node-semver#949 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] intersects() still returns true for an empty range against "*" (follow-up to #521)対応中かも @json-open-source が 36 日前に担当しました。 オープンBug Needs Triage
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
npm/node-semver#909 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
npm/node-semver の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Fei2411/DeepSeek-Bot#1113 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
arfct/timezone.fyi#19 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
fastify/fastify-http-proxy#493 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
eliasstravik/herdr-projects#785 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
tensorflow/tfjs#8754 ·