diff options
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -1404,4 +1404,23 @@ static function utf8_encode($latin1) return UConverter::transcode($latin1, 'UTF8', 'ISO-8859-1'); } +/** + * Parse xml and put any offending input into error report + */ +static function simplexml_load_string($data, $class_name = null, $options = 0) +{ + $oldsetting = libxml_use_internal_errors(true); + + if (($result = simplexml_load_string($data, $class_name, $options)) === false) + { + $titles = it::map('trim($v->message) . " at line $v->line col $v->column"', libxml_get_errors()); + it::error('title' => $titles[0], ['body' => join("\n", $titles) . "\n\n$data"]); + libxml_clear_errors(); + } + + libxml_use_internal_errors($oldsetting); + + return $result; +} + } |