Bob / fix_escape.py
yummyfiles's picture
Upload folder using huggingface_hub
dc4efed verified
Raw
History Blame Contribute Delete
617 Bytes
with open('app.js', 'r', encoding='utf-8') as f:
content = f.read()
# The issue is the escapeHtml function has smart quotes
# Find the line and replace with ASCII-only version
lines = content.split('\n')
for i, line in enumerate(lines):
if 'escapeHtml' in line and 'function' in line:
# Use chr() to build the replacement character map
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')