replace '&' with & when it is not in a character entity (approximation)
This commit is contained in:
parent
e2cc69a7e8
commit
bb33663472
|
@ -33,6 +33,7 @@ import tempfile
|
||||||
import sys
|
import sys
|
||||||
import collections
|
import collections
|
||||||
import warnings
|
import warnings
|
||||||
|
import re
|
||||||
|
|
||||||
def _deprecation_warning(message):
|
def _deprecation_warning(message):
|
||||||
warnings.warn(message, DeprecationWarning)
|
warnings.warn(message, DeprecationWarning)
|
||||||
|
@ -847,6 +848,10 @@ class _Request(object):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise MalformedResponseError(self.network, e)
|
raise MalformedResponseError(self.network, e)
|
||||||
|
|
||||||
|
# Pretty decent catch for invalid & characters - which last.fm
|
||||||
|
# seems to generate for some artist eg. "K'nann"
|
||||||
|
response_text = re.sub("&(?![^\W]+;)", "&", response_text)
|
||||||
|
|
||||||
self._check_response_for_errors(response_text)
|
self._check_response_for_errors(response_text)
|
||||||
return response_text
|
return response_text
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue