Skip to content

Commit 40ec36e

Browse files
author
Bryan Worrell
committed
Fixed issue where XML comments caused exceptions to be thrown. Fixes #64.
1 parent 3b03c61 commit 40ec36e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

stix/utils/parser.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@ def parse_xml_to_obj(self, xml_file, check_version=True, check_root=True):
6868
check_root -- Inspect the root element before parsing.
6969
7070
"""
71-
tree = None
72-
if check_version or check_root:
73-
tree = etree.parse(xml_file)
71+
parser = etree.ETCompatXMLParser(huge_tree=True)
72+
tree = etree.parse(xml_file, parser=parser)
7473

7574
if check_version:
7675
self._check_version(tree)
@@ -93,9 +92,8 @@ def parse_xml(self, xml_file, check_version=True, check_root=True):
9392
check_root -- Inspect the root element before parsing.
9493
9594
"""
96-
tree = None
97-
if check_version or check_root:
98-
tree = etree.parse(xml_file)
95+
parser = etree.ETCompatXMLParser(huge_tree=True)
96+
tree = etree.parse(xml_file, parser=parser)
9997

10098
if check_version:
10199
self._check_version(tree)

0 commit comments

Comments
 (0)