diff --git a/README.markdown b/README.markdown index f0dc33a..ecd095e 100644 --- a/README.markdown +++ b/README.markdown @@ -38,6 +38,7 @@ Authors Requirements ------------ +- Recent version of libxml2 >= 2.7.x (version 2.6.32 on Debian Lenny are not supported anymore) - PHP >= 5.3.7 - PHP XML extensions (SimpleXML, DOM...) - PHP Sqlite extension diff --git a/vendor/PicoFeed/Filter.php b/vendor/PicoFeed/Filter.php index e55cf77..dd6f526 100644 --- a/vendor/PicoFeed/Filter.php +++ b/vendor/PicoFeed/Filter.php @@ -115,16 +115,13 @@ class Filter // Workaround for old libxml2 (Debian Lenny) if (LIBXML_DOTTED_VERSION === '2.6.32') { - do { - $unique = md5(uniqid()); - } while(strpos($data, $unique) !== false); - $entity_alpha = array('&', '<', '>'); - $entity_num = array('&', '<', '>'); - $token = array($unique.'a', $unique.'l', $unique.'r'); - $data = str_replace($entity_alpha, $token, $data); - $data = str_replace($entity_num, $token, $data); - $data = html_entity_decode($data, ENT_NOQUOTES|ENT_XHTML, 'UTF-8'); - $data = str_replace($token, $entity_alpha, $data); + $entities = get_html_translation_table(HTML_ENTITIES, ENT_NOQUOTES|ENT_XHTML, 'UTF-8'); + + unset($entities['&']); + unset($entities['>']); + unset($entities['<']); + + $data = str_replace(array_values($entities), array_keys($entities), $data); } // Convert bad formatted documents to XML @@ -144,13 +141,7 @@ class Filter xml_set_element_handler($parser, 'startTag', 'endTag'); xml_set_character_data_handler($parser, 'dataTag'); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false); - - if (! xml_parse($parser, $this->input, true)) { - - //var_dump($this->input); - die(xml_get_current_line_number($parser).'|'.xml_error_string(xml_get_error_code($parser))); - } - + xml_parse($parser, $this->input, true); // We ignore parsing error (for old libxml) xml_parser_free($parser); return $this->data;