CHM Input: Handle files with deeply nested markup and non html files listed at the start of the manifest. Fixes #993607 (chm to mobi conversion crashes with "maximum recursion depth exceeded")

This commit is contained in:
Kovid Goyal 2012-05-03 17:56:20 +05:30
parent 226a26d208
commit 21c84615de

View File

@ -155,7 +155,10 @@ class CHMReader(CHMFile):
self.hhc_path = f
break
if self.hhc_path not in files and files:
self.hhc_path = files[0]
for f in files:
if f.partition('.')[-1].lower() in {'html', 'htm'}:
self.hhc_path = f
break
if self.hhc_path == '.hhc' and self.hhc_path not in files:
from calibre import walk
@ -241,7 +244,10 @@ class CHMReader(CHMFile):
except:
pass
# do not prettify, it would reformat the <pre> tags!
return str(soup)
try:
return str(soup)
except RuntimeError:
return data
def Contents(self):
if self._contents is not None: