Skip to content

Commit

Permalink
Fix SPDX expression split bug
Browse files Browse the repository at this point in the history
Signed-off-by: Wonjae Park <[email protected]>
  • Loading branch information
JustinWonjaePark committed Jul 15, 2024
1 parent 41d4083 commit 711f0c4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/fosslight_source/_parsing_scancode_file_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
KEYWORD_DOWNLOAD_LOC = r'DownloadLocation\s*[\S]+'
KEYWORD_SCANCODE_UNKNOWN = "unknown-spdx"
SPDX_REPLACE_WORDS = ["(", ")"]
KEY_AND = "and"
KEY_OR = "or"
KEY_AND = r"(?<=\s)and(?=\s)"
KEY_OR = r"(?<=\s)or(?=\s)"


def get_error_from_header(header_item):
Expand Down Expand Up @@ -182,8 +182,7 @@ def split_spdx_expression(spdx_string):
license = []
for replace in SPDX_REPLACE_WORDS:
spdx_string = spdx_string.replace(replace, "")
spdx_string = spdx_string.replace(KEY_OR, KEY_AND)
license = spdx_string.split(KEY_AND)
license = re.split(KEY_AND + "|" + KEY_OR, spdx_string)
return license


Expand Down

0 comments on commit 711f0c4

Please sign in to comment.