Catch invalid XML in suggestion response
As reported in #593, the XML response body returned for search suggestions can apparently contain invalid XML elements. This catches the error and returns an empty suggestion list instead of erroring. Fixes #593main
parent
362b6a75c8
commit
f4b65be876
|
@ -229,9 +229,13 @@ class Request:
|
||||||
if not response:
|
if not response:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
root = ET.fromstring(response)
|
try:
|
||||||
return [_.attrib['data'] for _ in
|
root = ET.fromstring(response)
|
||||||
root.findall('.//suggestion/[@data]')]
|
return [_.attrib['data'] for _ in
|
||||||
|
root.findall('.//suggestion/[@data]')]
|
||||||
|
except ET.ParseError:
|
||||||
|
# Malformed XML response
|
||||||
|
return []
|
||||||
|
|
||||||
def send(self, base_url='', query='', attempt=0,
|
def send(self, base_url='', query='', attempt=0,
|
||||||
force_mobile=False) -> Response:
|
force_mobile=False) -> Response:
|
||||||
|
|
Loading…
Reference in New Issue