Skip to content

Commit 48e22cf

Browse files
committed
Replace inalid license key characters
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 <[email protected]>
1 parent 40b981c commit 48e22cf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tern/formats/spdx/spdx_common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ def is_spdx_license_expression(license_data):
4848
'''Return True if the license is a valid SPDX license expression, else
4949
return False'''
5050
licensing = get_spdx_licensing()
51-
if ',' in license_data:
51+
if ',' in license_data or '/' in license_data:
5252
license_data = license_data.replace(',', ' and ')
53+
license_data = license_data.replace('/', '-')
5354
return licensing.validate(license_data).errors == []
5455

5556
def get_package_license_declared(package_license_declared):

0 commit comments

Comments
 (0)