Skip to content
Permalink
Browse files

Fix failing test.

Previously domdocument mode preserved CDATA blocks. Continue to do that
for domdocument mode and only strip cdata for SimpleXMLElement. This
could result in CDATA block showing up in data parsed by
RequestHandlerComponent but the toArray() conversion should clean those
up.

Refs #11818
  • Loading branch information...
markstory committed Mar 22, 2018
1 parent 23c8606 commit bbefe53ae955fd71f6ac8e9d6a62e7bd5eb3279f
Showing with 3 additions and 2 deletions.
  1. +2 −1 src/Utility/Xml.php
  2. +1 −1 tests/TestCase/Controller/Component/RequestHandlerComponentTest.php
@@ -145,12 +145,13 @@ protected static function _loadXml($input, $options)
if ($hasDisable && !$options['loadEntities']) {
libxml_disable_entity_loader(true);
}
$flags = LIBXML_NOCDATA;
$flags = 0;
if (!empty($options['parseHuge'])) {
$flags |= LIBXML_PARSEHUGE;
}
try {
if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') {
$flags |= LIBXML_NOCDATA;
$xml = new SimpleXMLElement($input, $flags);
} else {
$xml = new DOMDocument();
@@ -592,7 +592,7 @@ public function testStartupConvertXmlElements()
<?xml version="1.0" encoding="utf-8"?>
<article>
<id>1</id>
<title>first</title>
<title><![CDATA[first]]></title>
</article>
XML;
$this->Controller->request = new ServerRequest(['input' => $xml]);

0 comments on commit bbefe53

Please sign in to comment.
You can’t perform that action at this time.