mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing issue where Xml would not read CDATA blocks.
This commit is contained in:
parent
d771239104
commit
7aaf7e6b68
2 changed files with 15 additions and 2 deletions
|
@ -88,14 +88,14 @@ class Xml {
|
|||
return self::fromArray((array)$input, $options);
|
||||
} elseif (strpos($input, '<') !== false) {
|
||||
if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') {
|
||||
return new SimpleXMLElement($input);
|
||||
return new SimpleXMLElement($input, LIBXML_NOCDATA);
|
||||
}
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($input);
|
||||
return $dom;
|
||||
} elseif (file_exists($input) || strpos($input, 'http://') === 0 || strpos($input, 'https://') === 0) {
|
||||
if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') {
|
||||
return new SimpleXMLElement($input, null, true);
|
||||
return new SimpleXMLElement($input, LIBXML_NOCDATA, true);
|
||||
}
|
||||
$dom = new DOMDocument();
|
||||
$dom->load($input);
|
||||
|
|
|
@ -797,6 +797,19 @@ class XmlTest extends CakeTestCase {
|
|||
$this->assertEqual(str_replace(array("\r", "\n"), '', $xmlResponse->asXML()), $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that CDATA blocks don't get screwed up by SimpleXml
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testCdata() {
|
||||
$xml = '<' . '?xml version="1.0" encoding="UTF-8"?>' .
|
||||
'<people><name><![CDATA[ Mark ]]></name></people>';
|
||||
|
||||
$result = Xml::build($xml);
|
||||
$this->assertEquals(' Mark ', (string)$result->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for toArray() failures
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue