Code

Opened 4 years ago

Closed 2 years ago

#14202 closed Bug (fixed)

Rss201rev2Feed bug

Reported by: ZalivinDenis@… Owned by: tmitchell
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 4 years ago.
Reproducing the bug and that feed_url property is causing it
patch.diff (866 bytes) - added by fabian 4 years ago.
The patch to make it work (against trunk)
regression_tests.py (1.3 KB) - added by fabian 4 years ago.
Regression test to prove that the patch fixes the problem
patch2.diff (2.4 KB) - added by tmitchell 3 years ago.
Patch incorporating code and tests, applies cleanly to trunk

Download all attachments as: .zip

Change History (15)

comment:1 Changed 4 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
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']})

Changed 4 years ago by fabian

Reproducing the bug and that feed_url property is causing it

Changed 4 years ago by fabian

The patch to make it work (against trunk)

Changed 4 years ago by fabian

Regression test to prove that the patch fixes the problem

comment:2 Changed 4 years ago by fabian

  • 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 Changed 4 years ago by fabian

  • Triage Stage changed from Unreviewed to Accepted

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

comment:4 Changed 3 years ago by anonymous

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

comment:5 Changed 3 years ago by lrekucki

  • 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 Changed 3 years ago by tmitchell

  • Owner changed from nobody to tmitchell
  • Status changed from new to assigned

Changed 3 years ago by tmitchell

Patch incorporating code and tests, applies cleanly to trunk

comment:7 Changed 3 years ago by tmitchell

  • Patch needs improvement unset

comment:8 Changed 3 years ago by graham_king

  • Severity set to Normal
  • Type set to Bug

comment:9 Changed 2 years ago by anonymous

  • Easy pickings unset
  • UI/UX unset

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

comment:10 Changed 2 years ago by aaugustin

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 2 years ago by aaugustin (previous) (diff)

comment:11 Changed 2 years ago by aaugustin

  • Resolution set to fixed
  • Status changed from assigned to closed

In [17029]:

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.