File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
import requests
6
6
from lxml import etree # nosec
7
+ from lxml .etree import LxmlError # nosec
7
8
from xsdata .exceptions import ParserError
8
9
from xsdata .formats .dataclass .context import XmlContext
9
10
from xsdata .formats .dataclass .parsers import XmlParser
@@ -41,14 +42,19 @@ def _get_report_info(
41
42
if not response .content :
42
43
return None
43
44
44
- tree = etree .fromstring (response .content )
45
- node = tree .find (info_response_node )
45
+ try :
46
+ tree = etree .fromstring (response .content ).getroottree ()
47
+ node = tree .find (info_response_node )
48
+ except LxmlError :
49
+ return None
50
+
46
51
parser = XmlParser (context = XmlContext (), handler = LxmlEventHandler )
47
52
48
53
try :
49
54
info = parser .parse (node , info_type )
50
55
except ParserError :
51
56
return None
57
+
52
58
return info
53
59
54
60
You can’t perform that action at this time.
0 commit comments