Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-10483

RSS Redirects fail because of Snoopy's addition of :80 to URIs.



    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8, 1.8.1, 1.8.2
    • Fix Version/s: 1.9
    • Component/s: RSS
    • Labels:
    • Environment:
      Moodle 1.8.1,


      During our various Moodle workshops this summer, we've had the RSS feed block in Moodle fail on some, but not all, RSS feeds. The most prominent of these failures occurred with the BBC and Wall Street Journal feeds. When the failure occurs, Moodle says there was a problem fetching the feed, and that you should check it before using it in a block.

      If you didn't specify a title, the feed you added ends up being title-less, and can not be added to an RSS block.

      The problem lurks deep within the innards of Moodle, with the Snoopy object class that Magpie RSS uses to fetch URIs (Moodle in turn uses Magpie to parse the fetched RSS).

      The problem is that Snoopy (found in htdocs/lib/snoopy/Snoopy.class.inc) is indiscriminately adding a ":80" to all the URIs that it processes. For many sites this is not a problem, as the regular address and the one with :80 specified end up being the same. For others, it is.

      Case in point, the Wall Street Journal.

      The Wall Street Journal's RSS feeds (as of this writing) redirect to another RSS feed when you try to subscribe them. So this feed for "What's News"


      ends up redirecting to this feed:


      However, if you add a :80 to the original url (resulting in http://online.wsj.com:80/xml/rss/3_7011.xml) you end up getting redirected to the WSJ journal home page...


      ...which causes Magpie to return a 302 redirection error because Snoopy's not able to follow the redirect to its true destination. This ultimately causes web apps that rely on Magpie to parse RSS (like Moodle) to fail on what appears to be a perfectly OK RSS feed.

      Feed2JS (http://www.feed2js.org) would have the same problem, except its using a slightly older version of Snoopy that doesn't have this Port 80 logic included.

      <a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1671104&group_id=2091&atid=102091">This bug report on SourceForge outlines the problem</a>.

      <a href="http://trac.wordpress.org/ticket/3993">A good solution was posted to the Wordpress bug tracker</a>, which suggests changing the following code on line 799 of Snoopy.class.inc from:

      $headers .= ":".$this->port;


      if ($this->port != 80) {
      $headers .= ":".$this->port;

      This causes Snoopy to be more discriminate, only adding in the port when it's not :80. While this is technically a Snoopy problem rather than a Moodle one, it does occur in code that's part of the Moodle download.

      In addition, Moodle's RSS block has trouble evaluating the response from Magpie, which reports a 302 redirection error for the troublesome RSS feed. Moodle ignores this specific response, and instead gives a more generic one saying there was a problem parsing the feed. It then allows this non-feed to be added to the user's RSS library anyway. If you didn't specify a title for the feed, then it shows up blank in the list of available feeds under "configure this block".

      Given that no valid feed is returned from Magpie, I think it would be better if Moodle said the addition of the feed failed because of a broken redirect (or something to that effect). Fixing the underlying Snoopy problem should render this point moot, but in any case I think Moodle should simply prevent feeds with error codes from being added.


          Issue Links



              skodak Petr Skoda
              lafayettenuke Kenneth Newquist
              Andrew Davis
              Component watchers:
              Andrew Nicols, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              1 Vote for this issue
              2 Start watching this issue


                Fix Release Date: