mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-22 15:43:19 +02:00
Fix #874 (UnicodeDecodeError: in feeds2disk)
This commit is contained in:
parent
df883310c2
commit
5c8c683c2f
2 changed files with 7 additions and 2 deletions
|
|
@ -491,7 +491,9 @@ def escape(cls, text, quotes=True):
|
|||
if hasattr(text, '__html__'):
|
||||
return Markup(text.__html__())
|
||||
|
||||
text = unicode(text).replace('&', '&') \
|
||||
if isinstance(text, str):
|
||||
text = text.decode('utf-8', 'replace')
|
||||
text = text.replace('&', '&') \
|
||||
.replace('<', '<') \
|
||||
.replace('>', '>')
|
||||
if quotes:
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
__docformat__ = "restructuredtext en"
|
||||
|
||||
|
||||
import logging, os, cStringIO, time, traceback, re, urlparse
|
||||
import logging, os, cStringIO, time, traceback, re, urlparse, sys
|
||||
from collections import defaultdict
|
||||
from functools import partial
|
||||
|
||||
|
|
@ -533,6 +533,9 @@ def feed2index(self, feed):
|
|||
self.image_map[feed.image_url] = img
|
||||
except:
|
||||
pass
|
||||
if isinstance(feed.image_url, str):
|
||||
feed.image_url = feed.image_url.decode(sys.getfilesystemencoding(), 'strict')
|
||||
|
||||
|
||||
templ = templates.FeedTemplate()
|
||||
return templ.generate(feed, self.description_limiter).render(doctype='xhtml')
|
||||
|
|
|
|||
Loading…
Reference in a new issue