2014-07-04 08:11:46 +00:00
|
|
|
#!/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
|
|
|
|
|
2015-03-28 09:43:05 +00:00
|
|
|
data = re.sub(r'href="[^"]+"', aux, data)
|
|
|
|
data = re.sub(r'src="[^"]+"', aux, data)
|
2014-07-04 08:11:46 +00:00
|
|
|
|
|
|
|
with open(filename, "w") as f:
|
|
|
|
f.write(data)
|