From ee950ce4c76724e7cf85f135f697631f74242a87 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 17 Feb 2009 14:29:59 -0800 Subject: [PATCH] Fix #1870 (ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes) --- src/calibre/ebooks/html.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/html.py b/src/calibre/ebooks/html.py index b468e80246..340f5636eb 100644 --- a/src/calibre/ebooks/html.py +++ b/src/calibre/ebooks/html.py @@ -504,8 +504,14 @@ class Parser(PreProcessor, LoggingInterface): '

%s
'%err) self.head = self.root.xpath('./head')[0] self.body = self.root.body + invalid_counter = 0 for a in self.root.xpath('//a[@name]'): - a.set('id', a.get('name')) + try: + a.set('id', a.get('name')) + except: + invalid_counter += 1 + for x in ('id', 'name'): + a.set(x, 'calibre_invalid_id_%d'%invalid_counter) if not self.head.xpath('./title'): title = etree.SubElement(self.head, 'title') title.text = _('Unknown')