Skip to content

Commit 55f6f4d

Browse files
authored
Merge branch 'main' into 5.0.0-dev
2 parents 2a2b2dd + 5fa66a0 commit 55f6f4d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

cyclonedx/spdx.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ def is_compound_expression(value: str) -> bool:
6767
.. _SPDX license expression spec: https://spdx.github.io/spdx-spec/v2.3/SPDX-license-expressions/
6868
.. _license-expression library: https://github.com/nexB/license-expression
6969
"""
70-
return 0 == len(
71-
__SPDX_EXPRESSION_LICENSING.validate(value).errors
72-
)
70+
try:
71+
res = __SPDX_EXPRESSION_LICENSING.validate(value)
72+
except Exception:
73+
# the throw happens when internals crash due to unexpected input characters.
74+
return False
75+
return 0 == len(res.errors)

tests/test_spdx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def test_positive(self, valid_expression: str) -> None:
8989
'MIT AND Apache-2.0 OR something-unknown'
9090
'something invalid',
9191
'(c) John Doe',
92+
'Apache License, Version 2.0'
9293
)
9394
def test_negative(self, invalid_expression: str) -> None:
9495
actual = spdx.is_compound_expression(invalid_expression)

0 commit comments

Comments
 (0)