File size: 427 Bytes
ef6ccd9
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
with open('app.js', 'r', encoding='utf-8') as f:
    content = f.read()

lines = content.split('\n')
for i, line in enumerate(lines):
    if 'escapeHtml' in line and 'function' in line:
        lines[i] = 'function escapeHtml(s) { return s.replace(/[&<>]/g, c => ({"&":"&","<":"<",">":">"}[c])); }'
        print(f'Fixed line {i+1}')

with open('app.js', 'w', encoding='utf-8') as f:
    f.write('\n'.join(lines))
print('Done')