HTMLZ Output: Fix long title causing error on windows

HTMLZ Output: Fix long titles causing error when converting on windows.
Fixes #1235815 [Long titles with possible invalid chars cause errors during convert](https://bugs.launchpad.net/calibre/+bug/1235815)
This commit is contained in:
Kovid Goyal 2013-10-06 08:36:46 +05:30
parent 593d5174bf
commit a117d4c0b6

View File

@ -67,7 +67,8 @@ class HTMLZOutput(OutputFormatPlugin):
fname = u'index' fname = u'index'
if opts.htmlz_title_filename: if opts.htmlz_title_filename:
fname = ascii_filename(unicode(oeb_book.metadata.title[0])) from calibre.utils.filenames import shorten_components_to
fname = shorten_components_to(100, (ascii_filename(unicode(oeb_book.metadata.title[0])),))[0]
with open(os.path.join(tdir, fname+u'.html'), 'wb') as tf: with open(os.path.join(tdir, fname+u'.html'), 'wb') as tf:
tf.write(html) tf.write(html)