Skip to content

Commit 711f0c4

Browse files
Fix SPDX expression split bug
Signed-off-by: Wonjae Park <[email protected]>
1 parent 41d4083 commit 711f0c4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/fosslight_source/_parsing_scancode_file_item.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
KEYWORD_DOWNLOAD_LOC = r'DownloadLocation\s*[\S]+'
2727
KEYWORD_SCANCODE_UNKNOWN = "unknown-spdx"
2828
SPDX_REPLACE_WORDS = ["(", ")"]
29-
KEY_AND = "and"
30-
KEY_OR = "or"
29+
KEY_AND = r"(?<=\s)and(?=\s)"
30+
KEY_OR = r"(?<=\s)or(?=\s)"
3131

3232

3333
def get_error_from_header(header_item):
@@ -182,8 +182,7 @@ def split_spdx_expression(spdx_string):
182182
license = []
183183
for replace in SPDX_REPLACE_WORDS:
184184
spdx_string = spdx_string.replace(replace, "")
185-
spdx_string = spdx_string.replace(KEY_OR, KEY_AND)
186-
license = spdx_string.split(KEY_AND)
185+
license = re.split(KEY_AND + "|" + KEY_OR, spdx_string)
187186
return license
188187

189188

0 commit comments

Comments
 (0)