From 51314ce5d8b6af02751b714606017a0f28b36bc7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 5 Jan 2011 15:26:21 -0700 Subject: [PATCH] Content server: When serving OPDS feeds handle html descriptions taht have namespaced attributes. Fixes #7938 (Stanza shows some authors as "catalog is empty") --- src/calibre/library/server/opds.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/calibre/library/server/opds.py b/src/calibre/library/server/opds.py index fd8c50c594..ab0853add9 100644 --- a/src/calibre/library/server/opds.py +++ b/src/calibre/library/server/opds.py @@ -101,7 +101,19 @@ def html_to_lxml(raw): root = html.fragment_fromstring(raw) root.set('xmlns', "http://www.w3.org/1999/xhtml") raw = etree.tostring(root, encoding=None) - return etree.fromstring(raw) + try: + return etree.fromstring(raw) + except: + for x in root.iterdescendants(): + remove = [] + for attr in x.attrib: + if ':' in attr: + remove.append(attr) + for a in remove: + del x.attrib[a] + raw = etree.tostring(root, encoding=None) + return etree.fromstring(raw) + def CATALOG_ENTRY(item, item_kind, base_href, version, updated, ignore_count=False, add_kind=False):