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)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 25 - 7 = ?

 
 [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 http://workbench.cadenhead.org/news/3284/adding-atomlink-your-rss-feed 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 http://blog.mudrak.name/feed/?tag=mahara 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 +?>

Comments

 [2011-11-30 14:26 UTC] doconnor (Daniel O'Connor)
-Status: Open +Status: Analyzed
https://github.com/pear/XML_Feed_Parser/pull/2
 [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 pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net 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