diff --git a/ckanext/harvest/controllers/view.py b/ckanext/harvest/controllers/view.py index b3d0f94..b21d291 100644 --- a/ckanext/harvest/controllers/view.py +++ b/ckanext/harvest/controllers/view.py @@ -103,8 +103,10 @@ class ViewController(BaseController): content = obj['extras']['original_document'] else: abort(404,_('No content found')) - - etree.fromstring(re.sub('<\?xml(.*)\?>','',content)) + try: + etree.fromstring(re.sub('<\?xml(.*)\?>','',content)) + except UnicodeEncodeError: + etree.fromstring(re.sub('<\?xml(.*)\?>','',content.encode('utf-8'))) response.content_type = 'application/xml; charset=utf-8' if not '\n' + content