Skip to content

Commit

Permalink
Properly re.escape variant variable in find_used_variables_*
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Bargull <[email protected]>
  • Loading branch information
mbargull authored and kenodegard committed Apr 12, 2024
1 parent 024e61d commit 9a088ba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions conda_build/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ def find_used_variables_in_shell_script(variant, file_path):
text = f.read()
used_variables = set()
for v in variant:
variant_regex = r"(^[^$]*?\$\{?\s*%s\s*[\s|\}])" % v
variant_regex = rf"(^[^$]*?\$\{{?\s*{re.escape(v)}\s*[\s|\}}])"
if re.search(variant_regex, text, flags=re.MULTILINE | re.DOTALL):
used_variables.add(v)
return used_variables
Expand All @@ -774,7 +774,7 @@ def find_used_variables_in_batch_script(variant, file_path):
text = f.read()
used_variables = set()
for v in variant:
variant_regex = r"\%" + v + r"\%"
variant_regex = rf"\%{re.escape(v)}\%"
if re.search(variant_regex, text, flags=re.MULTILINE | re.DOTALL):
used_variables.add(v)
return used_variables

0 comments on commit 9a088ba

Please sign in to comment.