Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #8219 -- More robust date to string conversion in syndication f…

…eeds.

(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
  • Loading branch information...
commit 3b45a40c54993a36e2e56448326553e46a1b40d7 1 parent f67fb60
Malcolm Tredinnick authored

Showing 1 changed file with 12 additions and 12 deletions. Show diff stats Hide diff stats

  1. 24  django/utils/feedgenerator.py
24  django/utils/feedgenerator.py
@@ -81,7 +81,7 @@ def __init__(self, title, link, description, language=None, author_email=None,
81 81
 
82 82
     def add_item(self, title, link, description, author_email=None,
83 83
         author_name=None, author_link=None, pubdate=None, comments=None,
84  
-        unique_id=None, enclosure=None, categories=(), item_copyright=None, 
  84
+        unique_id=None, enclosure=None, categories=(), item_copyright=None,
85 85
         ttl=None, **kwargs):
86 86
         """
87 87
         Adds an item to the feed. All args are expected to be Python Unicode
@@ -118,26 +118,26 @@ def root_attributes(self):
118 118
         Called from write().
119 119
         """
120 120
         return {}
121  
-        
  121
+
122 122
     def add_root_elements(self, handler):
123 123
         """
124  
-        Add elements in the the root (i.e. feed/channel) element. Called 
  124
+        Add elements in the the root (i.e. feed/channel) element. Called
125 125
         from write().
126 126
         """
127 127
         pass
128  
-        
  128
+
129 129
     def item_attributes(self, item):
130 130
         """
131 131
         Return extra attributes to place on each item (i.e. item/entry) element.
132 132
         """
133 133
         return {}
134  
-        
  134
+
135 135
     def add_item_elements(self, handler, item):
136 136
         """
137 137
         Add elements on each item (i.e. item/entry) element.
138 138
         """
139 139
         pass
140  
-        
  140
+
141 141
     def write(self, outfile, encoding):
142 142
         """
143 143
         Outputs the feed in the given encoding to outfile, which is a file-like
@@ -204,7 +204,7 @@ def add_root_elements(self, handler):
204 204
             handler.addQuickElement(u"category", cat)
205 205
         if self.feed['feed_copyright'] is not None:
206 206
             handler.addQuickElement(u"copyright", self.feed['feed_copyright'])
207  
-        handler.addQuickElement(u"lastBuildDate", rfc2822_date(self.latest_post_date()).decode('ascii'))
  207
+        handler.addQuickElement(u"lastBuildDate", rfc2822_date(self.latest_post_date()).decode('utf-8'))
208 208
         if self.feed['ttl'] is not None:
209 209
             handler.addQuickElement(u"ttl", self.feed['ttl'])
210 210
 
@@ -238,7 +238,7 @@ def add_item_elements(self, handler, item):
238 238
             handler.addQuickElement(u"dc:creator", item["author_name"], {"xmlns:dc": u"http://purl.org/dc/elements/1.1/"})
239 239
 
240 240
         if item['pubdate'] is not None:
241  
-            handler.addQuickElement(u"pubDate", rfc2822_date(item['pubdate']).decode('ascii'))
  241
+            handler.addQuickElement(u"pubDate", rfc2822_date(item['pubdate']).decode('utf-8'))
242 242
         if item['comments'] is not None:
243 243
             handler.addQuickElement(u"comments", item['comments'])
244 244
         if item['unique_id'] is not None:
@@ -281,7 +281,7 @@ def add_root_elements(self, handler):
281 281
         if self.feed['feed_url'] is not None:
282 282
             handler.addQuickElement(u"link", "", {u"rel": u"self", u"href": self.feed['feed_url']})
283 283
         handler.addQuickElement(u"id", self.feed['id'])
284  
-        handler.addQuickElement(u"updated", rfc3339_date(self.latest_post_date()).decode('ascii'))
  284
+        handler.addQuickElement(u"updated", rfc3339_date(self.latest_post_date()).decode('utf-8'))
285 285
         if self.feed['author_name'] is not None:
286 286
             handler.startElement(u"author", {})
287 287
             handler.addQuickElement(u"name", self.feed['author_name'])
@@ -296,18 +296,18 @@ def add_root_elements(self, handler):
296 296
             handler.addQuickElement(u"category", "", {u"term": cat})
297 297
         if self.feed['feed_copyright'] is not None:
298 298
             handler.addQuickElement(u"rights", self.feed['feed_copyright'])
299  
-        
  299
+
300 300
     def write_items(self, handler):
301 301
         for item in self.items:
302 302
             handler.startElement(u"entry", self.item_attributes(item))
303 303
             self.add_item_elements(handler, item)
304 304
             handler.endElement(u"entry")
305  
-            
  305
+
306 306
     def add_item_elements(self, handler, item):
307 307
         handler.addQuickElement(u"title", item['title'])
308 308
         handler.addQuickElement(u"link", u"", {u"href": item['link'], u"rel": u"alternate"})
309 309
         if item['pubdate'] is not None:
310  
-            handler.addQuickElement(u"updated", rfc3339_date(item['pubdate']).decode('ascii'))
  310
+            handler.addQuickElement(u"updated", rfc3339_date(item['pubdate']).decode('utf-8'))
311 311
 
312 312
         # Author information.
313 313
         if item['author_name'] is not None:

0 notes on commit 3b45a40

Please sign in to comment.
Something went wrong with that request. Please try again.