mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Unquote URLs for images and stylesheets. Fixes #
This commit is contained in:
parent
b9314bcb25
commit
76959d8f95
@ -610,7 +610,7 @@ class HTMLConverter(object):
|
|||||||
self.add_text('Link: '+tag['href'], tag_css)
|
self.add_text('Link: '+tag['href'], tag_css)
|
||||||
self.links.append(HTMLConverter.Link(self.current_para.contents[-1], tag))
|
self.links.append(HTMLConverter.Link(self.current_para.contents[-1], tag))
|
||||||
elif tagname == 'img':
|
elif tagname == 'img':
|
||||||
if tag.has_key('src') and os.access(tag['src'], os.R_OK):
|
if tag.has_key('src') and os.access(unquote(tag['src']), os.R_OK):
|
||||||
width, height = self.page_width, self.page_height
|
width, height = self.page_width, self.page_height
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
@ -618,7 +618,7 @@ class HTMLConverter(object):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
im = PILImage.open(tag['src'])
|
im = PILImage.open(unquote(tag['src']))
|
||||||
width, height = im.size
|
width, height = im.size
|
||||||
if tag.has_key('width'):
|
if tag.has_key('width'):
|
||||||
width = int(tag['width'])
|
width = int(tag['width'])
|
||||||
@ -626,7 +626,7 @@ class HTMLConverter(object):
|
|||||||
height = int(tag['height'])
|
height = int(tag['height'])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
path = os.path.abspath(tag['src'])
|
path = os.path.abspath(unquote(tag['src']))
|
||||||
if not self.images.has_key(path):
|
if not self.images.has_key(path):
|
||||||
self.images[path] = ImageStream(path)
|
self.images[path] = ImageStream(path)
|
||||||
if max(width, height) <= min(self.page_width, self.page_height)/5.:
|
if max(width, height) <= min(self.page_width, self.page_height)/5.:
|
||||||
@ -647,7 +647,7 @@ class HTMLConverter(object):
|
|||||||
xsize=width, ysize=height)
|
xsize=width, ysize=height)
|
||||||
self.current_page.append(im)
|
self.current_page.append(im)
|
||||||
else:
|
else:
|
||||||
print >>sys.stderr, "Failed to process", tag
|
print >>sys.stderr, "Failed to process:", tag
|
||||||
|
|
||||||
self.add_image_page(tag['src'])
|
self.add_image_page(tag['src'])
|
||||||
elif tagname in ['style', 'link']:
|
elif tagname in ['style', 'link']:
|
||||||
@ -662,7 +662,7 @@ class HTMLConverter(object):
|
|||||||
if url.startswith('http://'):
|
if url.startswith('http://'):
|
||||||
f = urlopen(url)
|
f = urlopen(url)
|
||||||
else:
|
else:
|
||||||
f = open(url)
|
f = open(unquote(url))
|
||||||
self.parse_css(f.read())
|
self.parse_css(f.read())
|
||||||
f.close()
|
f.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user