Skip to content

Commit

Permalink
Merge pull request #35399 from dimagi/riese/defuse_xml
Browse files Browse the repository at this point in the history
Use defusexml
  • Loading branch information
MartinRiese authored Nov 19, 2024
2 parents bf19948 + 7510488 commit a0d0071
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions corehq/apps/app_manager/views/forms.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import hashlib
import json
import logging
import re
from xml.dom.minidom import parseString

from django.conf import settings
from django.contrib import messages
Expand Down Expand Up @@ -334,17 +332,6 @@ def should_edit(attribute):
xform = str(xform, encoding="utf-8")
except Exception:
raise Exception("Error uploading form: Please make sure your form is encoded in UTF-8")

if request.POST.get('cleanup', False):
try:
# First, we strip all newlines and reformat the DOM.
px = parseString(xform.replace('\r\n', '')).toprettyxml()
# Then we remove excess newlines from the DOM output.
text_re = re.compile(r'>\n\s+([^<>\s].*?)\n\s+</', re.DOTALL)
prettyXml = text_re.sub(r'>\g<1></', px)
xform = prettyXml
except Exception:
pass
if xform:
if isinstance(xform, str):
xform = xform.encode('utf-8')
Expand Down

0 comments on commit a0d0071

Please sign in to comment.