Opened 9 years ago

Closed 8 years ago

#1961 closed defect (fixed)

Feeds framework assumes feed link is a string

Reported by: ubernostrum Owned by: adrian
Component: contrib.syndication Version: master
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

When checking whether the link URL for a feed contains the domain name and 'http://' prefix, django/contrib/syndication/feeds.py assumes that it's been passed a string, when it may in fact have been passed a function which returns the URL.

Attachments (1)

feeds.diff (689 bytes) - added by mtredinnick 9 years ago.
Better patch (actually works now)

Download all attachments as: .zip

Change History (14)

comment:1 Changed 9 years ago by mtredinnick

oh @#$%! I somehow just nuked ubernostrum's original patch. He was patching add_domain() to call the url if it passed callable(url) testing.

/me goes to stand in the corner now.

comment:2 Changed 9 years ago by mtredinnick

That patch is just hosed. Do not use. Except for mocking. I'll write a more correct version later this evening or else revive ubernostrum's patch.

Changed 9 years ago by mtredinnick

Better patch (actually works now)

comment:3 Changed 9 years ago by mtredinnick

OK, here's a patch that does the same thing (treats feed_url) as a dynamic entity. I don't want to commit it yet, though, since I'm not entirely sure why it's needed. Currently feed_url is set to the full path of the feed requestand is used for the rel="self" link in the feed header. This is what the Atom spec recommends, for example. Why is this not enough?

comment:4 Changed 9 years ago by adrian

  • Resolution set to wontfix
  • Status changed from new to closed

Echoing mtredinnick's previous comment, I'm not sure this is needed. Why would the feed_url need to be dynamic?

comment:5 Changed 9 years ago by ubernostrum

  • Resolution wontfix deleted
  • Status changed from closed to reopened

#2218 was a duplicate of this.

Adrian, the problem here is with dynamically-generated things like per-category feeds; the URL string isn't known in advance, so it's necessary to have a function which returns the correct URL.

Also, the official docs for django.contrib.syndication advocate this in the "complex example", so we ought to make sure it works :)

comment:6 Changed 9 years ago by adrian

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

Fixed in [3409].

comment:7 Changed 9 years ago by benoit Chesneau <bchesneau@…>

  • Needs tests set

This bug is still here today. Trunk #4347 .

comment:8 Changed 9 years ago by mir@…

Hmm, how can this bug be reproduced?

comment:9 Changed 9 years ago by anonymous

i just install last django trunk. When I click on rss link it create an error.

comment:10 Changed 9 years ago by anonymous

error is :
AttributeError at /feeds/gallery/
'NoneType' object has no attribute 'startswith'
Request Method: GET
Request URL: http://192.168.1.2:8000/feeds/gallery/
Exception Type: AttributeError
Exception Value: 'NoneType' object has no attribute 'startswith'
Exception Location: /sw/lib/python2.4/site-packages/django/contrib/syndication/feeds.py in get_feed, line 69

comment:11 Changed 9 years ago by ubernostrum

  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening per request in #3348.

comment:12 Changed 9 years ago by SmileyChris

  • Has patch set
  • Triage Stage changed from Unreviewed to Accepted

comment:13 Changed 8 years ago by mtredinnick

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

Not sure why this is open / has been reopened. If somebody has a clear path to demonstrate a problem with the current code, reopen with an example.

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