lora-sp | 435e467 | 2023-03-13 13:53:07 +0100 | [diff] [blame] | 1 | import re |
| 2 | import sys |
| 3 | import xml.etree.ElementTree as ET |
| 4 | |
| 5 | def escape(file): |
| 6 | with open(sys.argv[i], "r+") as f: |
lora-sp | 435e467 | 2023-03-13 13:53:07 +0100 | [diff] [blame] | 7 | file = f.read() |
lora-sp | f6f000f | 2023-03-13 14:12:45 +0100 | [diff] [blame] | 8 | file = re.sub('&(?!gt;|apos;|quot;|lt;|amp;)', '&', file) |
lora-sp | 435e467 | 2023-03-13 13:53:07 +0100 | [diff] [blame] | 9 | f.seek(0) |
| 10 | f.write(file) |
| 11 | f.truncate() |
| 12 | |
| 13 | for i in range(1, len(sys.argv)): |
| 14 | try: |
| 15 | ET.parse(sys.argv[i]) |
| 16 | except: |
| 17 | escape(sys.argv[i]) |