MOBI Input: Always use index.html as the name of the generated html file to workaround problems with buggy epub readers that cannot handle URL unsafe characters in internal filenames

This commit is contained in:
Kovid Goyal 2014-07-10 10:04:20 +05:30
parent 9c8357c31b
commit cc05dee17e

View File

@ -17,7 +17,6 @@ except ImportError:
from lxml import html, etree from lxml import html, etree
from calibre import (xml_entity_to_unicode, entity_to_unicode) from calibre import (xml_entity_to_unicode, entity_to_unicode)
from calibre.utils.filenames import ascii_filename
from calibre.utils.cleantext import clean_ascii_chars from calibre.utils.cleantext import clean_ascii_chars
from calibre.ebooks import DRMError, unit_convert from calibre.ebooks import DRMError, unit_convert
from calibre.ebooks.chardet import ENCODING_PATS from calibre.ebooks.chardet import ENCODING_PATS
@ -265,12 +264,7 @@ class MobiReader(object):
self.read_embedded_metadata(root, metadata_elems[0], guide) self.read_embedded_metadata(root, metadata_elems[0], guide)
for elem in guides + metadata_elems: for elem in guides + metadata_elems:
elem.getparent().remove(elem) elem.getparent().remove(elem)
fname = self.name.encode('ascii', 'replace') htmlfile = os.path.join(output_dir, 'index.html')
fname = re.sub(r'[\x08\x15\0]+', '', fname)
if not fname:
fname = 'dummy'
htmlfile = os.path.join(output_dir,
ascii_filename(fname) + '.html')
try: try:
for ref in guide.xpath('descendant::reference'): for ref in guide.xpath('descendant::reference'):
if 'href' in ref.attrib: if 'href' in ref.attrib: