Skip to content

Commit fd4d537

Browse files
committed
feat: out-factor SPDX compund detection
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 3644f13 commit fd4d537

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

cyclonedx/spdx.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@ def is_compound_expression(value: str) -> bool:
5454
5555
.. _SPDX license expression spec: https://spdx.github.io/spdx-spec/v2.3/SPDX-license-expressions/
5656
"""
57-
return value.startswith('(') and value.endswith(')')
57+
# shortest known valid expression: (A or B) - 8 characters long
58+
return len(value) >= 8 \
59+
and value.startswith('(') \
60+
and value.endswith(')')

tests/test_spdx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def test_positive(self, valid_expression: str) -> None:
8888

8989
@data(
9090
'something invalid',
91+
'(c) John Doe'
9192
)
9293
def test_negative(self, invalid_expression: str) -> None:
9394
actual = spdx.is_compound_expression(invalid_expression)

0 commit comments

Comments
 (0)