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:
|
||||
return []
|
||||
|
||||
root = ET.fromstring(response)
|
||||
return [_.attrib['data'] for _ in
|
||||
root.findall('.//suggestion/[@data]')]
|
||||
try:
|
||||
root = ET.fromstring(response)
|
||||
return [_.attrib['data'] for _ in
|
||||
root.findall('.//suggestion/[@data]')]
|
||||
except ET.ParseError:
|
||||
# Malformed XML response
|
||||
return []
|
||||
|
||||
def send(self, base_url='', query='', attempt=0,
|
||||
force_mobile=False) -> Response:
|
||||
|
|
Loading…
Reference in New Issue