1
0
Fork 0

XML parsing is more tolerant now

This commit is contained in:
Michael 2017-09-25 21:34:44 +00:00
commit 8d95106b9d
2 changed files with 10 additions and 15 deletions

View file

@ -620,20 +620,15 @@ function avatar_img($email) {
}
function parse_xml_string($s,$strict = true) {
function parse_xml_string($s, $strict = true) {
// the "strict" parameter is deactivated
/// @todo Move this function to the xml class
if ($strict) {
if (! strstr($s,'<?xml'))
return false;
$s2 = substr($s,strpos($s,'<?xml'));
}
else
$s2 = $s;
libxml_use_internal_errors(true);
$x = @simplexml_load_string($s2);
if (! $x) {
logger('libxml: parse: error: ' . $s2, LOGGER_DATA);
$x = @simplexml_load_string($s);
if (!$x) {
logger('libxml: parse: error: ' . $s, LOGGER_DATA);
foreach (libxml_get_errors() as $err) {
logger('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, LOGGER_DATA);
}