Skip to content

Commit

Permalink
Replace inalid license key characters
Browse files Browse the repository at this point in the history
When a license is reported with invalid license keys (i.e. anything
besides letters and numbers, underscore, dot, colon or hyphen
signs and spaces) the `is_spdx_license_expression()` function fails
because the liense-expression library does not properly handle the
unknown characters. This commit is a workaround until the issue
opened in the license-expression library[1] is resolved.

Resolves #1199

[1] aboutcode-org/license-expression#76

Signed-off-by: Rose Judge <rjudge@vmware.com>
  • Loading branch information
rnjudge committed Dec 15, 2022
1 parent 40b981c commit 48e22cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tern/formats/spdx/spdx_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ def is_spdx_license_expression(license_data):
'''Return True if the license is a valid SPDX license expression, else
return False'''
licensing = get_spdx_licensing()
if ',' in license_data:
if ',' in license_data or '/' in license_data:
license_data = license_data.replace(',', ' and ')
license_data = license_data.replace('/', '-')
return licensing.validate(license_data).errors == []

def get_package_license_declared(package_license_declared):
Expand Down

0 comments on commit 48e22cf

Please sign in to comment.