E-book viewer: Fix failure to view comic files that contain non-ASCII characters int heir internal filenames. Fixes #1530517 [Bug with Viewer and Localized characters](https://bugs.launchpad.net/calibre/+bug/1530517)

This commit is contained in:
Kovid Goyal 2016-01-02 14:29:02 +05:30
parent bd4e970b3a
commit 6e4a31ac87
2 changed files with 8 additions and 3 deletions

View File

@ -232,9 +232,10 @@ class ComicInput(InputFormatPlugin):
def create_wrappers(self, pages): def create_wrappers(self, pages):
from calibre.ebooks.oeb.base import XHTML_NS from calibre.ebooks.oeb.base import XHTML_NS
wrappers = [] wrappers = []
WRAPPER = textwrap.dedent('''\ WRAPPER = textwrap.dedent(u'''\
<html xmlns="%s"> <html xmlns="%s">
<head> <head>
<meta charset="utf-8"/>
<title>Page #%d</title> <title>Page #%d</title>
<style type="text/css"> <style type="text/css">
@page { margin:0pt; padding: 0pt} @page { margin:0pt; padding: 0pt}
@ -253,7 +254,8 @@ class ComicInput(InputFormatPlugin):
for i, page in enumerate(pages): for i, page in enumerate(pages):
wrapper = WRAPPER%(XHTML_NS, i+1, os.path.basename(page), i+1) wrapper = WRAPPER%(XHTML_NS, i+1, os.path.basename(page), i+1)
page = os.path.join(dir, u'page_%d.xhtml'%(i+1)) page = os.path.join(dir, u'page_%d.xhtml'%(i+1))
open(page, 'wb').write(wrapper) with open(page, 'wb') as f:
f.write(wrapper.encode('utf-8'))
wrappers.append(page) wrappers.append(page)
return wrappers return wrappers

View File

@ -1493,7 +1493,10 @@ class OPFCreator(Metadata):
manifest = E.manifest() manifest = E.manifest()
if self.manifest is not None: if self.manifest is not None:
for ref in self.manifest: for ref in self.manifest:
item = E.item(id=str(ref.id), href=ref.href()) href = ref.href()
if isinstance(href, bytes):
href = href.decode('utf-8')
item = E.item(id=str(ref.id), href=href)
item.set('media-type', ref.mime_type) item.set('media-type', ref.mime_type)
manifest.append(item) manifest.append(item)
spine = E.spine() spine = E.spine()