Fixed #8219 -- More robust date to string conversion in syndication feeds.

(Sometimes) Affects people running in locales that use non-ASCII date strings.
Patch from alperkanat.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8397 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2008-08-15 22:13:50 +00:00
parent f67fb604ea
commit 3b45a40c54
1 changed files with 12 additions and 12 deletions

View File

@ -204,7 +204,7 @@ class RssFeed(SyndicationFeed):
handler.addQuickElement(u"category", cat) handler.addQuickElement(u"category", cat)
if self.feed['feed_copyright'] is not None: if self.feed['feed_copyright'] is not None:
handler.addQuickElement(u"copyright", self.feed['feed_copyright']) handler.addQuickElement(u"copyright", self.feed['feed_copyright'])
handler.addQuickElement(u"lastBuildDate", rfc2822_date(self.latest_post_date()).decode('ascii')) handler.addQuickElement(u"lastBuildDate", rfc2822_date(self.latest_post_date()).decode('utf-8'))
if self.feed['ttl'] is not None: if self.feed['ttl'] is not None:
handler.addQuickElement(u"ttl", self.feed['ttl']) handler.addQuickElement(u"ttl", self.feed['ttl'])
@ -238,7 +238,7 @@ class Rss201rev2Feed(RssFeed):
handler.addQuickElement(u"dc:creator", item["author_name"], {"xmlns:dc": u"http://purl.org/dc/elements/1.1/"}) handler.addQuickElement(u"dc:creator", item["author_name"], {"xmlns:dc": u"http://purl.org/dc/elements/1.1/"})
if item['pubdate'] is not None: if item['pubdate'] is not None:
handler.addQuickElement(u"pubDate", rfc2822_date(item['pubdate']).decode('ascii')) handler.addQuickElement(u"pubDate", rfc2822_date(item['pubdate']).decode('utf-8'))
if item['comments'] is not None: if item['comments'] is not None:
handler.addQuickElement(u"comments", item['comments']) handler.addQuickElement(u"comments", item['comments'])
if item['unique_id'] is not None: if item['unique_id'] is not None:
@ -281,7 +281,7 @@ class Atom1Feed(SyndicationFeed):
if self.feed['feed_url'] is not None: if self.feed['feed_url'] is not None:
handler.addQuickElement(u"link", "", {u"rel": u"self", u"href": self.feed['feed_url']}) handler.addQuickElement(u"link", "", {u"rel": u"self", u"href": self.feed['feed_url']})
handler.addQuickElement(u"id", self.feed['id']) handler.addQuickElement(u"id", self.feed['id'])
handler.addQuickElement(u"updated", rfc3339_date(self.latest_post_date()).decode('ascii')) handler.addQuickElement(u"updated", rfc3339_date(self.latest_post_date()).decode('utf-8'))
if self.feed['author_name'] is not None: if self.feed['author_name'] is not None:
handler.startElement(u"author", {}) handler.startElement(u"author", {})
handler.addQuickElement(u"name", self.feed['author_name']) handler.addQuickElement(u"name", self.feed['author_name'])
@ -307,7 +307,7 @@ class Atom1Feed(SyndicationFeed):
handler.addQuickElement(u"title", item['title']) handler.addQuickElement(u"title", item['title'])
handler.addQuickElement(u"link", u"", {u"href": item['link'], u"rel": u"alternate"}) handler.addQuickElement(u"link", u"", {u"href": item['link'], u"rel": u"alternate"})
if item['pubdate'] is not None: if item['pubdate'] is not None:
handler.addQuickElement(u"updated", rfc3339_date(item['pubdate']).decode('ascii')) handler.addQuickElement(u"updated", rfc3339_date(item['pubdate']).decode('utf-8'))
# Author information. # Author information.
if item['author_name'] is not None: if item['author_name'] is not None: