- prevent NULL from being handled over to XML::escape()
- still I wonder that an object can be? It is a string-only accepting method
This commit is contained in:
Roland Häder 2022-06-21 01:41:34 +02:00
parent 95f9eb34ac
commit 3e522ed512
No known key found for this signature in database
GPG Key ID: C82EDE5DDFA0BA77

View File

@ -56,7 +56,7 @@ class XML
$root = new SimpleXMLElement('<' . $key . '/>');
self::fromArray($value, $root, $remove_header, $namespaces, false);
} else {
$root = new SimpleXMLElement('<' . $key . '>'.self::escape($value).'</' . $key . '>');
$root = new SimpleXMLElement('<' . $key . '>' . self::escape($value ?? '') . '</' . $key . '>');
}
$dom = dom_import_simplexml($root)->ownerDocument;
@ -124,7 +124,7 @@ class XML
}
if (!is_array($value)) {
$element = $xml->addChild($key, self::escape($value), $namespace);
$element = $xml->addChild($key, self::escape($value ?? ''), $namespace);
} elseif (is_array($value)) {
$element = $xml->addChild($key, null, $namespace);
self::fromArray($value, $element, $remove_header, $namespaces, false);