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

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

    XMLWordPrintable

    Details

    • 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:
      None
    • Environment:
      Moodle 1.8.1,

      Description

      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"

      http://online.wsj.com/xml/rss/3_7011.xml

      ends up redirecting to this feed:

      http://feeds.wsjonline.com/wsj/xml/rss/3_7011.xml

      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...

      http://online.wsj.com/public/us

      ...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:

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

      to:

      if(!empty($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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                3/Mar/08