diff --git a/pylast.py b/pylast.py index c73f9e0..b3f9572 100644 --- a/pylast.py +++ b/pylast.py @@ -33,6 +33,7 @@ import tempfile import sys import collections import warnings +import re def _deprecation_warning(message): warnings.warn(message, DeprecationWarning) @@ -847,6 +848,10 @@ class _Request(object): except Exception as 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) return response_text