PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » XML » XML_RSS » Bug #3486

Ampersand lost in tranaslation

Details

Submitted2005-02-15 22:01 UTC
Frompcollett at citrusmotors dot com
Assignedmj
StatusClosed
PackageXML_RSS
PHP Version5.0.4.4
OSWinXP Pro
Roadmaps(Not assigned)

Comments

[2005-02-15 22:01 UTC] pcollett at citrusmotors dot com

Description:
------------
The ampersand in your example is lost in the slashdot.rdf link attributes when items are retrieved from XML_RSS.

it is in the RDF, and without the ampersand it changes the varibale going to slashdots page:
http://developers.slashdot.org/article.pl?sid=05/02/15/2031232from=rss
instead of
http://developers.slashdot.org/article.pl?sid=05/02/15/2031232&from=rss

Reproduce code:
---------------
example:
==
require_once "XML/RSS.php";

$rss =& new XML_RSS("http://slashdot.org/slashdot.rdf");
$rss->parse();

echo "<h1>Headlines from <a href=\"http://slashdot.org\">Slashdot</a></h1>\n";
echo "<ul>\n";

foreach ($rss->getItems() as $item) {
echo "<li><a href=\"" . $item['link'] . "\">" . $item['title'] . "</a></li>\n";
}

echo "</ul>\n";
==

Expected result:
----------------
http://developers.slashdot.org/article.pl?sid=05/02/15/2031232&from=rss

Actual result:
--------------
http://developers.slashdot.org/article.pl?sid=05/02/15/2031232from=rss

[2005-02-17 21:36 UTC] philmee95 at yahoo dot com

Overriding the handlers fixes the problem for me (pcollett @ yada yada.

I rebuilt the whole thing from a sitepoint article and ended up using almost all the Pear code (parser and this RSS). Finally figured it out.

function _initHandlers() {
xml_set_object( $this->parser, $this);
xml_set_element_handler( $this->parser, "startHandler", "endHandler");
xml_set_character_data_handler( $this->parser, "cdataHandler");
return true;
}

[2005-02-17 21:47 UTC] philmee95 at yahoo dot com

function _create() in XML_Parser passes a value to CLASS::_initHanlders(), and the function ( in v 1.21) doesn't take one. It is defaulted in the constructor of XML_Parser, and your extended RSS class. Maybe that is screwing stuff up. I have what works for me now, juts thought i would help as much as i could.

$result = $this->_initHandlers();
// me: $result = $this->_initHandlers($this->mode);

[2005-02-21 17:24 UTC] web at eteleon dot de

The ampersand is handled by the
defaultHandler($parser, $cdata) method, which just does
*nothing*!

Replace it with something like this:

public function defaultHandler($parser, $cdata)
{
$this->cdataHandler($parser, $cdata);
}

and it works...!

[2005-05-26 01:00 UTC] pcollett at citrusmotors dot com

seems to work in php 5.0.4.4. Although the sample script is timing out on the web request for some reason C:\php\PEAR\XML\Parser.php on line 469 (a fread loop of the file resource pointer w/ allow_url_fopen = On, but the local file rendition works fast with the "&"mpersands.

[2005-05-26 01:03 UTC] pcollett at citrusmotors dot com

mj,
nm, works fine. My astaro fire wall was filtering the content from slashdot.org. was it that libxml bug i read about?

Thanks,
Phil

[2005-05-26 18:05 UTC] pcollett at citrusmotors dot com

guess i should have closed it?