Fix #874 (UnicodeDecodeError: in feeds2disk)

This commit is contained in:
Kovid Goyal 2008-07-31 05:26:31 -07:00
parent df883310c2
commit 5c8c683c2f
2 changed files with 7 additions and 2 deletions

View File

@ -491,7 +491,9 @@ class Markup(unicode):
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('<', '&lt;') \
.replace('>', '&gt;')
if quotes:

View File

@ -7,7 +7,7 @@ Defines various abstract base classes that can be subclassed to create powerful
__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 @@ class BasicNewsRecipe(object, LoggingInterface):
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')