Bob / fix_escape2.py
yummyfiles's picture
Upload folder using huggingface_hub
ef6ccd9 verified
Raw
History Blame Contribute Delete
481 Bytes
with open('app.js', 'r', encoding='utf-8') as f:
content = f.read()
# Fix the escapeHtml function properly
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')