lol

Merge pull request #226937 from rhendric/rhendric/update-python-libraries

update-python-libraries: escape vars in regexes

authored by

Martin Weinelt and committed by
GitHub
abc97d35 a63e9647

+3 -3
+3 -3
pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py
··· 65 65 66 66 :returns: List of matches. 67 67 """ 68 - regex = '{}\s+=\s+"(.*)";'.format(attribute) 68 + regex = '{}\s+=\s+"(.*)";'.format(re.escape(attribute)) 69 69 regex = re.compile(regex) 70 70 values = regex.findall(text) 71 71 return values ··· 103 103 def _get_line_and_value(attribute, text, value=None): 104 104 """Match attribute in text. Return the line and the value of the attribute.""" 105 105 if value is None: 106 - regex = rf'({attribute}\s+=\s+\"(.*)\";)' 106 + regex = rf'({re.escape(attribute)}\s+=\s+\"(.*)\";)' 107 107 else: 108 - regex = rf'({attribute}\s+=\s+\"({value})\";)' 108 + regex = rf'({re.escape(attribute)}\s+=\s+\"({re.escape(value)})\";)' 109 109 regex = re.compile(regex) 110 110 results = regex.findall(text) 111 111 n = len(results)