From a10c7f9a359bfdae3d18eaedf8178fe8f58486e7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 16 Oct 2014 08:05:29 +0530 Subject: [PATCH] AZW3 Output: Ignore invalid attribute names in the input document rather than aborting the conversion on them. --- src/calibre/ebooks/mobi/writer8/skeleton.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/mobi/writer8/skeleton.py b/src/calibre/ebooks/mobi/writer8/skeleton.py index 45282b56fd..94f7bfc673 100644 --- a/src/calibre/ebooks/mobi/writer8/skeleton.py +++ b/src/calibre/ebooks/mobi/writer8/skeleton.py @@ -237,9 +237,12 @@ class Chunker(object): tn = tag.tag if tn is not None: tn = tn.rpartition('}')[-1] - elem = nroot.makeelement(tn, - attrib={k.rpartition('}')[-1]:v for k, v in - tag.attrib.iteritems()}) + attrib = {k.rpartition('}')[-1]:v for k, v in tag.attrib.iteritems()} + try: + elem = nroot.makeelement(tn, attrib=attrib) + except ValueError: + attrib = {k:v for k, v in attrib.iteritems() if ':' not in k} + elem = nroot.makeelement(tn, attrib=attrib) elem.text = tag.text elem.tail = tag.tail parent = node_from_path(nroot, path_to_node(tag.getparent()))