DOCX Output: Fix images that use URL unsafe characters in their filenames being dropped during conversion. Fixes #1873571 [remove pic when i chang ebook to docx](https://bugs.launchpad.net/calibre/+bug/1873571)

This commit is contained in:
Kovid Goyal 2020-04-20 08:41:34 +05:30
parent f27ca196d8
commit 63eea9fa35
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -14,7 +14,7 @@ from polyglot.builtins import iteritems, itervalues, map, unicode_type
from lxml import etree
from calibre import fit_image
from calibre.ebooks.oeb.base import urlunquote
from calibre.ebooks.oeb.base import urlunquote, urlquote
from calibre.ebooks.docx.images import pt_to_emu
from calibre.utils.filenames import ascii_filename
from calibre.utils.imghdr import identify
@ -50,8 +50,9 @@ class ImagesManager(object):
def read_image(self, href):
if href not in self.images:
item = self.oeb.manifest.hrefs.get(href)
item = self.oeb.manifest.hrefs.get(href) or self.oeb.manifest.hrefs.get(urlquote(href))
if item is None or not isinstance(item.data, bytes):
self.log.warning('Failed to find image:', href)
return
try:
fmt, width, height = identify(item.data)