Wrapped more code in an exception block, in order not to continue processing after an XML parse exception. Fixes issue #2885.
- Legacy-Id: 17305
This commit is contained in:
parent
aabd237656
commit
9439f718d4
|
@ -187,8 +187,6 @@ class SubmissionBaseUploadForm(forms.Form):
|
|||
self.xmltree = parser.parse(remove_comments=False, quiet=True)
|
||||
self.xmlroot = self.xmltree.getroot()
|
||||
xml_version = self.xmlroot.get('version', '2')
|
||||
except Exception as e:
|
||||
self.add_error('xml', "An exception occurred when trying to parse the XML file: %s" % e)
|
||||
|
||||
draftname = self.xmlroot.attrib.get('docName')
|
||||
if draftname is None:
|
||||
|
@ -296,6 +294,13 @@ class SubmissionBaseUploadForm(forms.Form):
|
|||
[ forms.ValidationError("One or more XML validation errors occurred when processing the XML file:") ] +
|
||||
[ forms.ValidationError("%s: Line %s: %s" % (xml_file.name, r.line, r.message), code="%s"%r.type) for r in errors ]
|
||||
)
|
||||
except Exception as e:
|
||||
try:
|
||||
msgs = format_messages('txt', e, xml2rfc.log)
|
||||
log.log('\n'.join(msgs))
|
||||
self.add_error('xml', msgs)
|
||||
except Exception:
|
||||
self.add_error('xml', "An exception occurred when trying to process the XML file: %s" % e)
|
||||
finally:
|
||||
os.close(tfh)
|
||||
os.unlink(tfn)
|
||||
|
|
Loading…
Reference in a new issue