Fix #5666 (coverter UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 57: unexpected code byte)

This commit is contained in:
Kovid Goyal 2010-06-02 14:08:17 -06:00
parent 3a12b18dc3
commit 6221f67473
3 changed files with 9 additions and 3 deletions

View File

@ -416,9 +416,9 @@ class HTMLInput(InputFormatPlugin):
link = unquote(link).replace('/', os.sep)
if not link.strip():
return link_
if base and not os.path.isabs(link):
link = os.path.join(base, link)
try:
if base and not os.path.isabs(link):
link = os.path.join(base, link)
link = os.path.abspath(link)
except:
return link_

View File

@ -11,7 +11,7 @@ import re
from calibre.ebooks.metadata import MetaInformation
from calibre.ebooks.chardet import xml_to_unicode
from calibre import entity_to_unicode
def get_metadata(stream):
src = stream.read()
@ -43,6 +43,10 @@ def get_metadata_(src, encoding=None):
if match:
author = match.group(2).replace(',', ';')
ent_pat = re.compile(r'&(\S+)?;')
title = ent_pat.sub(entity_to_unicode, title)
if author:
author = ent_pat.sub(entity_to_unicode, author)
mi = MetaInformation(title, [author] if author else None)
# Publisher

View File

@ -51,6 +51,8 @@ class FontMetrics(object):
def get_font_metrics(image, d_wand, text):
if isinstance(text, unicode):
text = text.encode('utf-8')
ret = p.MagickQueryFontMetrics(image, d_wand, text)
return FontMetrics(ret)