-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fix "invalid lib version" crash #7920
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
Fix "invalid lib version" crash #7920
Conversation
This helps to avoid bugs similar to arduino#7917
✅ Build completed. Please test this code using one of the following: ⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-7920-BUILD-758-linux32.tar.xz ℹ️ The |
|
||
UserLibrary res = new UserLibrary(); | ||
res.installedFolder = libFolder; | ||
res.name = properties.get("name").trim(); | ||
res.version = version.toString(); | ||
res.version = version.isPresent() ? version.get().toString() : declaredVersion; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could using "declaredVersion" have unintended consequences? As I understand this, it would allow libraries to put any arbitrary string into Arduino's data structures. Is everything else in the Arduino code able to handle any arbitrary text, when it's all been designed around the until-now strictly enforced major.minor.patch format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version
field for user libraries has always been a String
and the format has never been forced to be semver compliant.
To compare version "strings" we use the VersionComparator
class that compares two different version "strings", say A and B, using the following alogrithm:
- parse A and B as semver
- if both A and B are valid semver, compare them using semver rules
- if A is valid semver but not B, then A is the greatest
- if B is valid semver but not A, then B is the greatest
- if both A and B are not valid semver, consider them equals
This logic allows libraires that are not semver compliant to soft transition to semver (since a valid semver version is always greater).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, sounds like you've thought this through quite carefully. I was thinking simpler less-is-more in #7922, after having a user reports 1.8.6 unable to start up.
Fixes #3215 |
Fix #7917
The actual fix is 6e030b8, BTW I've added some more commits to clean up things out.