From 9ea1b7e95b8a47e3b40d1f4d958ed79b0db5e76b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 9 Sep 2014 08:18:39 +0530 Subject: [PATCH] Fix #1366889 [ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters](https://bugs.launchpad.net/calibre/+bug/1366889) --- src/calibre/ebooks/oeb/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 0fcdf2ea25..bd0599b880 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -20,6 +20,7 @@ from calibre.ebooks.conversion.preprocess import CSSPreProcessor from calibre import (isbytestring, as_unicode, get_types_map) from calibre.ebooks.oeb.parse_utils import (barename, XHTML_NS, RECOVER_PARSER, namespace, XHTML, parse_html, NotHTML) +from calibre.utils.cleantext import clean_xml_chars XML_NS = 'http://www.w3.org/XML/1998/namespace' OEB_DOC_NS = 'http://openebook.org/namespaces/oeb-document/1.0/' @@ -238,7 +239,7 @@ def rewrite_links(root, link_repl_func, resolve_base_href=False): repl = stylesheet.cssText if isbytestring(repl): repl = repl.decode('utf-8') - el.text = '\n'+ repl + '\n' + el.text = '\n'+ clean_xml_chars(repl) + '\n' if 'style' in el.attrib: text = el.attrib['style']