EPUB Output: Fix crash caused by ids with non-ascii characters in them

This commit is contained in:
Kovid Goyal 2011-05-31 11:28:37 -06:00
parent 37ddce4074
commit 5c219da8d3

View File

@ -120,7 +120,19 @@ class Split(object):
for i, x in enumerate(page_breaks): for i, x in enumerate(page_breaks):
x.set('id', x.get('id', 'calibre_pb_%d'%i)) x.set('id', x.get('id', 'calibre_pb_%d'%i))
id = x.get('id') id = x.get('id')
page_breaks_.append((XPath('//*[@id=%r]'%id), try:
xp = XPath('//*[@id="%s"]'%id)
except:
try:
xp = XPath("//*[@id='%s']"%id)
except:
# The id has both a quote and an apostrophe or some other
# Just replace it since I doubt its going to work anywhere else
# either
id = 'calibre_pb_%d'%i
x.set('id', id)
xp = XPath('//*[@id=%r]'%id)
page_breaks_.append((xp,
x.get('pb_before', False))) x.get('pb_before', False)))
page_break_ids.append(id) page_break_ids.append(id)