-
Notifications
You must be signed in to change notification settings - Fork 41
Improve license parsing error handling #309
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
Conversation
Checks simple license tokens to make sure they are either a listed license or a LicenseRef- Fixes #227
|
@goneall this is probably a separate issue, unrelated to this PR, but I'm not seeing any parsing of |
src/main/java/org/spdx/utility/license/LicenseExpressionParser.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Arthit Suriyawongkul <[email protected]> Signed-off-by: Gary O'Neall <[email protected]>
Good catch @pmonks - In looking at the license addition code, I realized I'm not taking into account external license refs which is yet another issue. I'll add a check for the |
|
@goneall if it's helpful, here are the regexes I use in my own parser for LicenseRefs & AdditionRefs (the values inside the ; LicenseRefs:
#"(DocumentRef-(?<DocumentRef>[\p{Alnum}-\.]+):)?LicenseRef-(?<LicenseRef>[\p{Alnum}-\.]+)"
; AdditionRefs:
#"(DocumentRef-(?<AdditionDocumentRef>[\p{Alnum}-\.]+):)?AdditionRef-(?<AdditionRef>[\p{Alnum}-\.]+)"Clojure is hosted on the JVM, so these regexes will also work in Spdx-Java-Library (albeit with escaping as needed for a Java string literal that then gets compiled to a Oh and note that these regexes make use of named capturing groups for extracting the custom sections of the |
Turns out I was checking for external license refs (first line of the method), so I only need to add the additional check for the additionref syntax. @pmonks - let me know if I missed anything |
bact
left a comment
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.
Minor changes, adding 'a'.
src/main/java/org/spdx/utility/license/LicenseExpressionParser.java
Outdated
Show resolved
Hide resolved
src/main/java/org/spdx/utility/license/LicenseExpressionParser.java
Outdated
Show resolved
Hide resolved
src/main/java/org/spdx/utility/license/LicenseExpressionParser.java
Outdated
Show resolved
Hide resolved
src/test/java/org/spdx/utility/license/LicenseExpressionParserTest.java
Outdated
Show resolved
Hide resolved
….java Signed-off-by: Arthit Suriyawongkul <[email protected]>
….java Signed-off-by: Arthit Suriyawongkul <[email protected]>
….java Signed-off-by: Arthit Suriyawongkul <[email protected]>
…Test.java Signed-off-by: Arthit Suriyawongkul <[email protected]>
Checks simple license tokens to make sure they are either a listed license or a LicenseRef-
Fixes #227