Skip to content

Commit

Permalink
Properly re.escape variant variable in find_used_variables_* (#5283)
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
Co-authored-by: Marcel Bargull <marcel.bargull@udo.edu>
  • Loading branch information
kenodegard and mbargull authored Apr 17, 2024
1 parent 2d3270d commit 28b51fb
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 @@ -771,7 +771,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 @@ -782,7 +782,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 28b51fb

Please sign in to comment.