Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.5

Bug #16416 atom:link causes getLink to fail for RSS2.php
Submitted: 2009-07-09 09:59 UTC
From: crimson Assigned: crimson
Status: Closed Package: XML_Feed_Parser (version 1.0.3)
PHP Version: 5.2.5 OS: Debian Lenny
Roadmaps: (Not assigned)    

 [2009-07-09 09:59 UTC] crimson (Crimson Fire)
Description: ------------ The RSS 2.0 spec specifies that you should use <link> however some sites such as recommend adding <atom:link /> also. getElementsByTagName will return both these links when searching for 'link'. If the atom:link is first then $link->nodeValue is an empty string and this eventually calls combineBases passing $element->baseURI (which in my case ends up being the folder of the file) An example of the kind of feed that can trigger this is I have attached a diff of my change to fix this issue using xpath to only match <link> and not <atom:link> (or any other namespaced link attributes). Actual result: -------------- ben@tifa:Parser/$ git diff diff --git a/htdocs/lib/pear/XML/Feed/Parser/RSS2.php b/htdocs/lib/pear/XML/Feed/Parser/RSS2.php index c5d79d1..308a4ab 100644 --- a/htdocs/lib/pear/XML/Feed/Parser/RSS2.php +++ b/htdocs/lib/pear/XML/Feed/Parser/RSS2.php @@ -321,7 +321,8 @@ class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type */ function getLink($offset, $attribute = 'href', $params = array()) { - $links = $this->model->getElementsByTagName('link'); + $xPath = new DOMXPath($this->model); + $links = $xPath->query('//link'); if ($links->length <= $offset) { return false; @@ -331,4 +332,4 @@ class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type } } -?> \ No newline at end of file +?>


 [2011-11-30 14:26 UTC] doconnor (Daniel O'Connor)
-Status: Open +Status: Analyzed
 [2011-11-30 14:45 UTC] doconnor (Daniel O'Connor)
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: doconnor
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.
 [2011-11-30 14:45 UTC] doconnor (Daniel O'Connor)
-Assigned To: doconnor +Assigned To: crimson