Opened 14 years ago

Closed 12 years ago

#14202 closed Bug (fixed)

Rss201rev2Feed bug

Reported by: ZalivinDenis@… Owned by: Taylor Mitchell
Component: contrib.syndication Version: 1.2
Severity: Normal Keywords: Rss201rev2Feed, feedgenerator
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Bug with ...

Even exhample, given here is not working:

>>> from django.utils import feedgenerator
>>> feed = feedgenerator.Rss201rev2Feed(
...     title=u"Poynter E-Media Tidbits",
...     link=u"http://www.poynter.org/column.asp?id=31",
...     description=u"A group weblog by the sharpest minds in online media/journalism/publishing.",
...     language=u"en",
... )
>>> feed.add_item(
...     title="Hello",
...     link=u"http://www.holovaty.com/test/",
...     description="Testing."
... )
>>> fp = open('test.rss', 'w')
>>> feed.write(fp, 'utf-8')

/home/denis/svn/trunk/env/django121/django/utils/feedgenerator.pyc in write(self, outfile, encoding)
    201         handler.startElement(u"rss", self.rss_attributes())
    202         handler.startElement(u"channel", self.root_attributes())
--> 203         self.add_root_elements(handler)
    204         self.write_items(handler)
    205         self.endChannelElement(handler)

/home/denis/svn/trunk/env/django121/django/utils/feedgenerator.pyc in add_root_elements(self, handler)
    220         handler.addQuickElement(u"link", self.feed['link'])
    221         handler.addQuickElement(u"description", self.feed['description'])
--> 222         handler.addQuickElement(u"atom:link", None, {u"rel": u"self", u"href": self.feed['feed_url']})
    223         if self.feed['language'] is not None:
    224             handler.addQuickElement(u"language", self.feed['language'])

/home/denis/svn/trunk/env/django121/django/utils/xmlutils.py in addQuickElement(self, name, contents, attrs)
     10         print '>>>>>>>>>>', attrs
     11         if attrs is None: attrs = {}
---> 12         self.startElement(name, attrs)
     13         if contents is not None:
     14             self.characters(contents)

/usr/lib/python2.5/xml/sax/saxutils.pyc in startElement(self, name, attrs)
    130         self._write('<' + name)
    131         for (name, value) in attrs.items():
--> 132             self._write(' %s=%s' % (name, quoteattr(value)))
    133         self._write('>')
    134 

/usr/lib/python2.5/xml/sax/saxutils.pyc in quoteattr(data, entities)
     71     entities = entities.copy()
     72     entities.update({'\n': '&#10;', '\r': '&#13;', '\t':'&#9;'})
---> 73     data = escape(data, entities)
     74     if '"' in data:
     75         if "'" in data:

/usr/lib/python2.5/xml/sax/saxutils.pyc in escape(data, entities)
     37 
     38     # must do ampersand first
---> 39     data = data.replace("&", "&amp;")
     40     data = data.replace(">", "&gt;")
     41     data = data.replace("<", "&lt;")

AttributeError: 'NoneType' object has no attribute 'replace'

Attachments (4)

reproduction_tests.py (858 bytes ) - added by Fabian Topfstedt 14 years ago.
Reproducing the bug and that feed_url property is causing it
patch.diff (866 bytes ) - added by Fabian Topfstedt 14 years ago.
The patch to make it work (against trunk)
regression_tests.py (1.3 KB ) - added by Fabian Topfstedt 14 years ago.
Regression test to prove that the patch fixes the problem
patch2.diff (2.4 KB ) - added by Taylor Mitchell 13 years ago.
Patch incorporating code and tests, applies cleanly to trunk

Download all attachments as: .zip

Change History (15)

comment:1 by anonymous, 14 years ago

10         print '>>>>>>>>>>', attrs

This is my debug string.

self.feedfeed_url is None here:

--> 222         handler.addQuickElement(u"atom:link", None, {u"rel": u"self", u"href": self.feed['feed_url']})

by Fabian Topfstedt, 14 years ago

Attachment: reproduction_tests.py added

Reproducing the bug and that feed_url property is causing it

by Fabian Topfstedt, 14 years ago

Attachment: patch.diff added

The patch to make it work (against trunk)

by Fabian Topfstedt, 14 years ago

Attachment: regression_tests.py added

Regression test to prove that the patch fixes the problem

comment:2 by Fabian Topfstedt, 14 years ago

Has patch: set

The bug actually concerned django.utils.feedgenerators.RssFeed (which Rss201rev2Feed inherits from). I patched it so that RssFeeds without a feed_url do not render the "atom:link" attribute which is not required by RSS (see http://bit.ly/bAZpKT) and wrote a regression test.

comment:3 by Fabian Topfstedt, 14 years ago

Triage Stage: UnreviewedAccepted

It's an obvious bug and (sticking to the docs) I bypass the ticket triangers and accept it.

comment:4 by anonymous, 13 years ago

Does anyone know why this ticket (being accepted) is not in trunk?

comment:5 by Łukasz Rekucki, 13 years ago

Patch needs improvement: set

Maybe, because it doesn't have a trunk ready patch which someone can review ?

The patch should include both the fix and unit tests integrated into Django's test suite. The tests are already there, they just need to be put into the right place.

comment:6 by Taylor Mitchell, 13 years ago

Owner: changed from nobody to Taylor Mitchell
Status: newassigned

by Taylor Mitchell, 13 years ago

Attachment: patch2.diff added

Patch incorporating code and tests, applies cleanly to trunk

comment:7 by Taylor Mitchell, 13 years ago

Patch needs improvement: unset

comment:8 by Graham King, 13 years ago

Severity: Normal
Type: Bug

comment:9 by anonymous, 12 years ago

Easy pickings: unset
UI/UX: unset

why is this still not fixed ? in 1.2.7 ? or even in 1.3.1 ?

comment:10 by Aymeric Augustin, 12 years ago

Since this isn't a major problem, per the backport policy, it is going to be fixed in trunk only, not in the stable banches.

I'm going to commit the fix.

Last edited 12 years ago by Aymeric Augustin (previous) (diff)

comment:11 by Aymeric Augustin, 12 years ago

Resolution: fixed
Status: assignedclosed

In [17029]:

Fixed #14202 -- made the atom:link element optional in feeds.

Note: See TracTickets for help on using tickets.
Back to Top