mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #5666 (coverter UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 57: unexpected code byte)
This commit is contained in:
parent
3a12b18dc3
commit
6221f67473
@ -416,9 +416,9 @@ class HTMLInput(InputFormatPlugin):
|
|||||||
link = unquote(link).replace('/', os.sep)
|
link = unquote(link).replace('/', os.sep)
|
||||||
if not link.strip():
|
if not link.strip():
|
||||||
return link_
|
return link_
|
||||||
if base and not os.path.isabs(link):
|
|
||||||
link = os.path.join(base, link)
|
|
||||||
try:
|
try:
|
||||||
|
if base and not os.path.isabs(link):
|
||||||
|
link = os.path.join(base, link)
|
||||||
link = os.path.abspath(link)
|
link = os.path.abspath(link)
|
||||||
except:
|
except:
|
||||||
return link_
|
return link_
|
||||||
|
@ -11,7 +11,7 @@ import re
|
|||||||
|
|
||||||
from calibre.ebooks.metadata import MetaInformation
|
from calibre.ebooks.metadata import MetaInformation
|
||||||
from calibre.ebooks.chardet import xml_to_unicode
|
from calibre.ebooks.chardet import xml_to_unicode
|
||||||
|
from calibre import entity_to_unicode
|
||||||
|
|
||||||
def get_metadata(stream):
|
def get_metadata(stream):
|
||||||
src = stream.read()
|
src = stream.read()
|
||||||
@ -43,6 +43,10 @@ def get_metadata_(src, encoding=None):
|
|||||||
if match:
|
if match:
|
||||||
author = match.group(2).replace(',', ';')
|
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)
|
mi = MetaInformation(title, [author] if author else None)
|
||||||
|
|
||||||
# Publisher
|
# Publisher
|
||||||
|
@ -51,6 +51,8 @@ class FontMetrics(object):
|
|||||||
|
|
||||||
|
|
||||||
def get_font_metrics(image, d_wand, text):
|
def get_font_metrics(image, d_wand, text):
|
||||||
|
if isinstance(text, unicode):
|
||||||
|
text = text.encode('utf-8')
|
||||||
ret = p.MagickQueryFontMetrics(image, d_wand, text)
|
ret = p.MagickQueryFontMetrics(image, d_wand, text)
|
||||||
return FontMetrics(ret)
|
return FontMetrics(ret)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user