Skip to content
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

Issue with hyphen sign when used in build and pre release section #16

Open
KristianShishoev opened this issue Oct 16, 2017 · 4 comments

Comments

@KristianShishoev
Copy link

According to specification versions with hyphen sign in build section should be valid versions.
In our project when we try to parse such versions we recieve exception.
Example version: 1.2.3+123-abc

Also when there are more than one hyphen sign in pre release section version is not parsed correctly.
For example if we have following version: 1.2.3-alpha-abc+123 when parsed it gets cut to 1.2.3-alpha-abc+123

@rupebac
Copy link

rupebac commented Nov 16, 2017

I confirm, the issue happens also in the subversion. ie:
1.2+ should be a valid requirement, according to:

http://ant.apache.org/ivy/history/2.1.0/settings/version-matchers.html

@CCFenner
Copy link

CCFenner commented Feb 28, 2018

We have the same issue with the NPM Requirement that pre-releases with a - within are not parsed correctly (NPE).

see tests

@mattcree
Copy link

mattcree commented Sep 23, 2020

I am seeing an issue here as well when parsing NPM Requirements. I'm using version 3.1.0

Example ^2.26.3-1 (this is something out there in the wild -- a library called wiremock-standalone)

When this is parsed, the first item on the list is a HYPHEN type token, so it goes down the 'upper and lower' path.

Screenshot 2020-09-23 at 11 17 18

On lines 336 and 337 of Requirement.java, you are trying to get two more parts, expecting that it's the left and right side of the range, but since there's a caret, you are getting the caret in token2.

In the Semver class constructor, calling 'trim()' on the value is causing an NPE.

When you use a non number i.e. ^2.26.3-beta, on the right hand side it correctly detects the type as NPM.

So the root cause for my issue is because it is interpreting the Requirement as the wrong type of range i.e. not a caret range, but a hyphen range.

@piotrooo
Copy link

@KristianShishoev if you are still interesting, I've made copy of this lib and fix bug reported by you. Look for version 2.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants