diff --git a/Parser/Type.php b/Parser/Type.php index 5b4145f..244a58e 100644 --- a/Parser/Type.php +++ b/Parser/Type.php @@ -331,10 +331,19 @@ function processXHTMLAttributes($node) { * @param String * @return String */ - function processEntitiesForNodeValue($value) + function processEntitiesForNodeValue($node) { - $decoded = html_entity_decode($value, NULL, 'utf-8'); - return htmlentities($decoded, NULL, 'utf-8'); + if (function_exists('iconv')) { + $current_encoding = $node->ownerDocument->encoding; + $value = iconv($current_encoding, 'UTF-8', $node->nodeValue); + } else if ($current_encoding == 'iso-8859-1') { + $value = utf8_encode($node->nodeValue); + } else { + $value = $node->nodeValue; + } + + $decoded = html_entity_decode($value, NULL, 'UTF-8'); + return htmlentities($decoded, NULL, 'UTF-8'); } /** @@ -366,7 +375,7 @@ function traverseNode($node) } if ($node instanceof DOMText) { - $content .= $this->processEntitiesForNodeValue($node->nodeValue); + $content .= $this->processEntitiesForNodeValue($node); } /* Add the closing of this node to the content */ diff --git a/package2.xml b/package2.xml index 36928d7..1950da8 100644 --- a/package2.xml +++ b/package2.xml @@ -14,10 +14,10 @@ http://pear.php.net/dtd/package-2.0.xsd"> james@jystewart.net yes - 2007-04-09 - + 2008-11-19 + - 1.0.2 + 1.0.3 1.0.0 @@ -25,8 +25,15 @@ http://pear.php.net/dtd/package-2.0.xsd"> stable LGPL - Fixed bug #10499 - AtomElement's xpath is NULL (thanks to Teo Hui Ming) - Fixed bug #10501 -- atom getLink() should query links without rel in special case (thanks to Teo Hui Ming) + + Bug fix release. Closes: + #13215 - Encoding problems + #12919 - &amp; in ULR's causes problems + #12522 - pubDate handler throws warning on empty field + #12017 - no rss2 image if <itunes:image/> precedes <image> + #11467 - Escaped HTML in Atom Text Constructs + #10702 - Indirect modification of overloaded property + #10336 - Error with encoding handling on xhtml @@ -151,6 +158,19 @@ http://pear.php.net/dtd/package-2.0.xsd"> + + + 1.0.3 + 1.0.1 + + + stable + stable + + 2008-11-19 + PHP License + Maintenance release + 1.0.2 @@ -162,7 +182,16 @@ http://pear.php.net/dtd/package-2.0.xsd"> 2007-01-09 PHP License - + +Bug fix release. Closes: +#13215 - Encoding problems +#12919 - &amp; in ULR's causes problems +#12522 - pubDate handler throws warning on empty field +#12017 - no rss2 image if <itunes:image/> precedes <image> +#11467 - Escaped HTML in Atom Text Constructs +#10702 - Indirect modification of overloaded property +#10336 - Error with encoding handling on xhtml + diff --git a/tests/regressions.php b/tests/regressions.php index 50d71a8..bda880b 100644 --- a/tests/regressions.php +++ b/tests/regressions.php @@ -58,9 +58,8 @@ function test_handlesMultipleEnclosuresInAtom() $this->assertEquals('http://example.org/audio/ph34r_my_podcast2.mp3', $second['url']); } - /** - * German umlauts (ÄÖÜäöüß) from an atom xml file (encoding="iso-8859-1") + * German umlauts (ÄÖÜäöüß) from an atom xml file (encoding="iso-8859-1") * are displayed wrong after parsing, eg. http://www.keine-gentechnik.de/news-regionen.xml * * @url http://pear.php.net/bugs/bug.php?id=12916 @@ -70,6 +69,9 @@ function test_handlesGermanUmlauts() $xml = file_get_contents($this->sample_dir . "/bug12916.xml"); $feed = new XML_Feed_Parser($xml); $entry = $feed->getEntryById('sample-feed:1'); + + // Ensure that the parsed XML equals the input XML + // $this->assertEquals($xml, (string)$feed); $this->assertEquals('ÄÜÖäüöß', $entry->title); $this->assertEquals('ÄÜÖäüöß', $entry->content); }