Fix syntax for Python 3.12

Backslash needs escaping now.  Otherwise one sees:

.../XSStrike/core/dom.py:27: SyntaxWarning: invalid escape sequence '\$'
  controlledVariables.add(re.search(r'[a-zA-Z$_][a-zA-Z0-9$_]+', part).group().replace('$', '\$'))
.../XSStrike/core/dom.py:36: SyntaxWarning: invalid escape sequence '\$'
  controlledVariables.add(re.search(r'[a-zA-Z$_][a-zA-Z0-9$_]+', part).group().replace('$', '\$'))

Signed-off-by: Peter Chubb <Peter.Chubb@unsw.edu.au>
This commit is contained in:
Peter Chubb
2025-02-15 20:20:47 +11:00
parent f292787604
commit 3f46fee699

View File

@@ -24,7 +24,7 @@ def dom(response):
for part in parts: for part in parts:
for controlledVariable in allControlledVariables: for controlledVariable in allControlledVariables:
if controlledVariable in part: if controlledVariable in part:
controlledVariables.add(re.search(r'[a-zA-Z$_][a-zA-Z0-9$_]+', part).group().replace('$', '\$')) controlledVariables.add(re.search(r'[a-zA-Z$_][a-zA-Z0-9$_]+', part).group().replace('$', '\\$'))
pattern = re.finditer(sources, newLine) pattern = re.finditer(sources, newLine)
for grp in pattern: for grp in pattern:
if grp: if grp:
@@ -33,7 +33,7 @@ def dom(response):
if len(parts) > 1: if len(parts) > 1:
for part in parts: for part in parts:
if source in part: if source in part:
controlledVariables.add(re.search(r'[a-zA-Z$_][a-zA-Z0-9$_]+', part).group().replace('$', '\$')) controlledVariables.add(re.search(r'[a-zA-Z$_][a-zA-Z0-9$_]+', part).group().replace('$', '\\$'))
line = line.replace(source, yellow + source + end) line = line.replace(source, yellow + source + end)
for controlledVariable in controlledVariables: for controlledVariable in controlledVariables:
allControlledVariables.add(controlledVariable) allControlledVariables.add(controlledVariable)