|
40 | 40 |
|
41 | 41 | import fs |
42 | 42 | import xml.dom.minidom |
43 | | -import xml.parsers.expat |
| 43 | +import defusedxml.minidom |
| 44 | +from defusedxml import DefusedXmlException |
44 | 45 |
|
45 | 46 | from PyQt5 import QtGui, QtCore, QtWidgets |
46 | 47 |
|
|
55 | 56 | from mslib.msui.performance_settings import DEFAULT_PERFORMANCE |
56 | 57 |
|
57 | 58 | from mslib.utils import writexml |
58 | | -xml.dom.minidom.Element.writexml = writexml |
| 59 | +xml.dom.minidom.Element.writexml = writexml # nosec, we take care of writing correct XML |
59 | 60 | # Constants for identifying the table columns when the WaypointsTableModel is |
60 | 61 | # used with a QTableWidget. |
61 | 62 | LOCATION, LAT, LON, FLIGHTLEVEL, PRESSURE = list(range(5)) |
@@ -97,8 +98,8 @@ def seconds_to_string(seconds): |
97 | 98 |
|
98 | 99 | def load_from_xml_data(xml_content, name="Flight track"): |
99 | 100 | try: |
100 | | - doc = xml.dom.minidom.parseString(xml_content) |
101 | | - except xml.parsers.expat.ExpatError as ex: |
| 101 | + doc = defusedxml.minidom.parseString(xml_content) |
| 102 | + except DefusedXmlException as ex: |
102 | 103 | raise SyntaxError(str(ex)) |
103 | 104 |
|
104 | 105 | ft_el = doc.getElementsByTagName("FlightTrack")[0] |
@@ -615,7 +616,7 @@ def save_to_ftml(self, filename=None): |
615 | 616 | file_dir.close() |
616 | 617 |
|
617 | 618 | def get_xml_doc(self): |
618 | | - doc = xml.dom.minidom.Document() |
| 619 | + doc = xml.dom.minidom.Document() # nosec, we take care of writing correct XML |
619 | 620 | ft_el = doc.createElement("FlightTrack") |
620 | 621 | ft_el.setAttribute("version", __version__) |
621 | 622 | doc.appendChild(ft_el) |
|
0 commit comments