From 632d9f994f1203815bfc00a530c115be8dad5c1d Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 12 Feb 2011 19:12:14 +0000 Subject: [PATCH] Fixed #15237 -- Always set charset of Atom1 feeds to UTF-8. Thanks, Simon and jasonkotenko. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15505 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/syndication/views.py | 3 +-- django/utils/feedgenerator.py | 2 +- tests/regressiontests/utils/feedgenerator.py | 9 +++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/django/contrib/syndication/views.py b/django/contrib/syndication/views.py index 9228e91687..dbb9eee4ab 100644 --- a/django/contrib/syndication/views.py +++ b/django/contrib/syndication/views.py @@ -1,9 +1,8 @@ -import datetime from django.conf import settings from django.contrib.sites.models import get_current_site from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist from django.http import HttpResponse, Http404 -from django.template import loader, Template, TemplateDoesNotExist, RequestContext +from django.template import loader, TemplateDoesNotExist, RequestContext from django.utils import feedgenerator, tzinfo from django.utils.encoding import force_unicode, iri_to_uri, smart_unicode from django.utils.html import escape diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py index 15476f8b0f..a49e16be5c 100644 --- a/django/utils/feedgenerator.py +++ b/django/utils/feedgenerator.py @@ -291,7 +291,7 @@ class Rss201rev2Feed(RssFeed): class Atom1Feed(SyndicationFeed): # Spec: http://atompub.org/2005/07/11/draft-ietf-atompub-format-10.html - mime_type = 'application/atom+xml' + mime_type = 'application/atom+xml; charset=utf8' ns = u"http://www.w3.org/2005/Atom" def write(self, outfile, encoding): diff --git a/tests/regressiontests/utils/feedgenerator.py b/tests/regressiontests/utils/feedgenerator.py index c62bd2b03a..26c60ea420 100644 --- a/tests/regressiontests/utils/feedgenerator.py +++ b/tests/regressiontests/utils/feedgenerator.py @@ -60,3 +60,12 @@ class FeedgeneratorTest(unittest.TestCase): "2008-11-14T13:37:00+02:00" ) + def test_atom1_mime_type(self): + """ + Test to make sure Atom MIME type has UTF8 Charset parameter set + """ + atom_feed = feedgenerator.Atom1Feed("title", "link", "description") + self.assertEqual( + atom_feed.mime_type, "application/atom+xml; charset=utf8" + ) +