diff options
author | michael <michael@content-space.de> | 2008-12-29 22:33:41 +0100 |
---|---|---|
committer | michael <michael@content-space.de> | 2008-12-29 22:33:41 +0100 |
commit | 8285d596bc77e829954be44ccfe8958b1d0387ae (patch) | |
tree | 6a7314056c9bdae468460daa84ed523b9e58714b | |
parent | 8ace41274b7fc9c16a98e5f30d0429724ce0895a (diff) | |
download | rpg-8285d596bc77e829954be44ccfe8958b1d0387ae.tar.gz rpg-8285d596bc77e829954be44ccfe8958b1d0387ae.tar.bz2 |
Workaround for a PHP/libxml-bug with entities
As described on http://bugs.php.net/bug.php?idE996, current versions of libxml (2.7.0/1) lead to the fact that the xml parser of PHP eats predefined entities. As proposed on http://bugs.simplepie.org/issues/show/101 predefined entities are replaced by their numeric equivalents. There is no condition in this patch as there are people reporting it isn't gone in 2.7.2, i can confirm that, and furthermore here PHP is reporting libxml 20632 and the bug exists, too (it is linked to libxml2 though which has version 2.7.2). As soon as there is definite knowledge on which versions are actually concerned and how to detect them in PHP a condition should be added as this patch might decrease the performance of the affected functions.
darcs-hash:20081229213341-074e0-10e0cca836c6599efe4d3dfd45f512d624d0a808.gz
-rw-r--r-- | inc/IXR_Library.php | 6 | ||||
-rw-r--r-- | inc/SimplePie.php | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/inc/IXR_Library.php b/inc/IXR_Library.php index fb11585ca..ae77f2c27 100644 --- a/inc/IXR_Library.php +++ b/inc/IXR_Library.php @@ -144,6 +144,12 @@ class IXR_Message { function parse() { // first remove the XML declaration $this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message); + // workaround for a bug in PHP/libxml2, see http://bugs.php.net/bug.php?id=45996 + $this->message = str_replace('<', '<', $this->message); + $this->message = str_replace('>', '>', $this->message); + $this->message = str_replace('&', '&', $this->message); + $this->message = str_replace(''', ''', $this->message); + $this->message = str_replace('"', '"', $this->message); if (trim($this->message) == '') { return false; } diff --git a/inc/SimplePie.php b/inc/SimplePie.php index 390b7e0a0..b5dab727f 100644 --- a/inc/SimplePie.php +++ b/inc/SimplePie.php @@ -10297,6 +10297,13 @@ class SimplePie_Parser xml_set_character_data_handler($this->xml, 'cdata'); xml_set_element_handler($this->xml, 'tag_open', 'tag_close'); + // workound for a bug in PHP/libxml2 as described on http://bugs.simplepie.org/issues/show/101 + $data = str_replace('<', '<', $data); + $data = str_replace('>', '>', $data); + $data = str_replace('&', '&', $data); + $data = str_replace(''', ''', $data); + $data = str_replace('"', '"', $data); + // Parse! if (!xml_parse($this->xml, $data, true)) { |