From a0cefcf7042a7b68bcd4989d4d055f22728571b8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 6 Jul 2015 20:32:03 +0530 Subject: [PATCH] Edit Book/Book polishing: Fix EPUB files with opf files that use a non-default namespace for the OPF namespace being corrupted. Fixes #1471419 [Private bug](https://bugs.launchpad.net/calibre/+bug/1471419) --- src/calibre/ebooks/oeb/polish/container.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/oeb/polish/container.py b/src/calibre/ebooks/oeb/polish/container.py index 6a5ff8f076..c576d2d3a1 100644 --- a/src/calibre/ebooks/oeb/polish/container.py +++ b/src/calibre/ebooks/oeb/polish/container.py @@ -825,12 +825,12 @@ class Container(object): # {{{ def serialize_item(self, name): ''' Convert a parsed object (identified by canonical name) into a bytestring. See :meth:`parsed`. ''' - data = self.parsed(name) + data = root = self.parsed(name) if name == self.opf_name: self.format_opf() data = serialize(data, self.mime_map[name], pretty_print=name in self.pretty_print) - if name == self.opf_name: + if name == self.opf_name and root.nsmap.get(None) == OPF2_NS: # Needed as I can't get lxml to output opf:role and # not output as well data = re.sub(br'(<[/]{0,1})opf:', r'\1', data)