You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
482 B
Python

#!/usr/bin/env python3
import re
import sys
for filename in sys.argv[1:]:
try:
with open(filename) as f:
data = f.read()
except UnicodeDecodeError:
continue
def aux(match):
s = match.group(0)
s = s.replace("?", "%3F")
s = s.replace("&", "%26")
return s
data = re.sub(r'href="[^"]+"', aux, data)
data = re.sub(r'src="[^"]+"', aux, data)
with open(filename, "w") as f:
f.write(data)