Fix #1870 (ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes)

This commit is contained in:
Kovid Goyal 2009-02-17 14:29:59 -08:00
parent 2f7f23580f
commit ee950ce4c7

View File

@ -504,8 +504,14 @@ class Parser(PreProcessor, LoggingInterface):
'</p><pre>%s</pre></body></html>'%err)
self.head = self.root.xpath('./head')[0]
self.body = self.root.body
invalid_counter = 0
for a in self.root.xpath('//a[@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')