Try to refactoring old libxml support (but now it's not supported officially)
This commit is contained in:
parent
0a91f85f65
commit
80f44c5311
@ -38,6 +38,7 @@ Authors
|
|||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
- Recent version of libxml2 >= 2.7.x (version 2.6.32 on Debian Lenny are not supported anymore)
|
||||||
- PHP >= 5.3.7
|
- PHP >= 5.3.7
|
||||||
- PHP XML extensions (SimpleXML, DOM...)
|
- PHP XML extensions (SimpleXML, DOM...)
|
||||||
- PHP Sqlite extension
|
- PHP Sqlite extension
|
||||||
|
25
vendor/PicoFeed/Filter.php
vendored
25
vendor/PicoFeed/Filter.php
vendored
@ -115,16 +115,13 @@ class Filter
|
|||||||
// Workaround for old libxml2 (Debian Lenny)
|
// Workaround for old libxml2 (Debian Lenny)
|
||||||
if (LIBXML_DOTTED_VERSION === '2.6.32') {
|
if (LIBXML_DOTTED_VERSION === '2.6.32') {
|
||||||
|
|
||||||
do {
|
$entities = get_html_translation_table(HTML_ENTITIES, ENT_NOQUOTES|ENT_XHTML, 'UTF-8');
|
||||||
$unique = md5(uniqid());
|
|
||||||
} while(strpos($data, $unique) !== false);
|
unset($entities['&']);
|
||||||
$entity_alpha = array('&', '<', '>');
|
unset($entities['>']);
|
||||||
$entity_num = array('&', '<', '>');
|
unset($entities['<']);
|
||||||
$token = array($unique.'a', $unique.'l', $unique.'r');
|
|
||||||
$data = str_replace($entity_alpha, $token, $data);
|
$data = str_replace(array_values($entities), array_keys($entities), $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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert bad formatted documents to XML
|
// Convert bad formatted documents to XML
|
||||||
@ -144,13 +141,7 @@ class Filter
|
|||||||
xml_set_element_handler($parser, 'startTag', 'endTag');
|
xml_set_element_handler($parser, 'startTag', 'endTag');
|
||||||
xml_set_character_data_handler($parser, 'dataTag');
|
xml_set_character_data_handler($parser, 'dataTag');
|
||||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
|
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
|
||||||
|
xml_parse($parser, $this->input, true); // We ignore parsing error (for old libxml)
|
||||||
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_parser_free($parser);
|
xml_parser_free($parser);
|
||||||
|
|
||||||
return $this->data;
|
return $this->data;
|
||||||
|
Loading…
Reference in New Issue
Block a user