Ticket #15237: 15237-rss.patch

File 15237-rss.patch, 1.3 KB (added by michal@…, 3 years ago)

Added charset to RSS feeds

  • django/utils/feedgenerator.py

    diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
    index df3cf41..592d787 100644
    a b class Enclosure(object): 
    200200        self.url = iri_to_uri(url)
    201201
    202202class RssFeed(SyndicationFeed):
    203     mime_type = 'application/rss+xml'
     203    mime_type = 'application/rss+xml; charset=utf-8'
    204204    def write(self, outfile, encoding):
    205205        handler = SimplerXMLGenerator(outfile, encoding)
    206206        handler.startDocument()
  • tests/regressiontests/utils/feedgenerator.py

    diff --git a/tests/regressiontests/utils/feedgenerator.py b/tests/regressiontests/utils/feedgenerator.py
    index 6b85abf..3990896 100644
    a b class FeedgeneratorTest(unittest.TestCase): 
    8787            atom_feed.mime_type, "application/atom+xml; charset=utf-8"
    8888        )
    8989
     90    def test_rss_mime_type(self):
     91        """
     92        Test to make sure RSS MIME type has UTF8 Charset parameter set
     93        """
     94        rss_feed = feedgenerator.Rss201rev2Feed("title", "link", "description")
     95        self.assertEqual(
     96            rss_feed.mime_type, "application/rss+xml; charset=utf-8"
     97        )
     98
    9099    # Two regression tests for #14202
    91100
    92101    def test_feed_without_feed_url_gets_rendered_without_atom_link(self):
Back to Top