spdx / tools

SPDX Tools
Apache License 2.0
123 stars 68 forks source link

LicenseInfoFactory.parseSPDXLicenseString Fails for License Strings Containing WITH Operator #268

Closed aschet closed 3 years ago

aschet commented 3 years ago

With version 2.1.0 it was possible to parse license strings containing the WITH operator with the LicenseInfoFactory.parseSPDXLicenseString method: LicenseInfoFactory.parseSPDXLicenseString("MIT WITH Autoconf-exception-2.0");

With version 2.2.4 the same call causes the following exception: org.spdx.spdxspreadsheet.InvalidLicenseStringException: Unexpected SPDX error parsing license string

goneall commented 3 years ago

The error is coming from the parsing of the LicenseException:

https://github.com/spdx/tools/blob/1c3ada864c279516fbbb27299ae29358edd38404/src/org/spdx/rdfparser/license/LicenseException.java#L151

With the recent update of the license list to version 3.12, the RDF file is now including the type in the object value for isDeprecated. Previously, it was false, it is now stored as false^^http://www.w3.org/2001/XMLSchema#boolean.

This can be fixed by parsing out the ^^http://www.w3.org/2001/XMLSchema#boolean before the compares.

There may be other values in the license or exceptions that may now contain the type (e.g. other boolean values).

goneall commented 3 years ago

@aschet You might want to try the same function in the Spdx-Java-Library or tools-java. These are redesigned implementations of the SPDX Java libraries. I verified that the same problem does not exist in the new libraries.

goneall commented 3 years ago

Resolved in release 2.2.5