[Serializer] fixed bc-break with cdata-section nodes
This commit is contained in:
parent
9c60a8582e
commit
48d9f36ea0
@ -305,7 +305,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
|
|||||||
return $node->nodeValue;
|
return $node->nodeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 === $node->childNodes->length && XML_TEXT_NODE === $node->firstChild->nodeType) {
|
if (1 === $node->childNodes->length && in_array($node->firstChild->nodeType, array(XML_TEXT_NODE, XML_CDATA_SECTION_NODE))) {
|
||||||
return $node->firstChild->nodeValue;
|
return $node->firstChild->nodeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +228,18 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(get_object_vars($obj), $this->encoder->decode($source, 'xml'));
|
$this->assertEquals(get_object_vars($obj), $this->encoder->decode($source, 'xml'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDecodeCdataWrapping()
|
||||||
|
{
|
||||||
|
$expected = array(
|
||||||
|
'firstname' => 'Paul <or Me>',
|
||||||
|
);
|
||||||
|
|
||||||
|
$xml = '<?xml version="1.0"?>'."\n".
|
||||||
|
'<response><firstname><![CDATA[Paul <or Me>]]></firstname></response>'."\n";
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $this->encoder->decode($xml, 'xml'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testDecodeScalarWithAttribute()
|
public function testDecodeScalarWithAttribute()
|
||||||
{
|
{
|
||||||
$source = '<?xml version="1.0"?>'."\n".
|
$source = '<?xml version="1.0"?>'."\n".
|
||||||
|
Reference in New Issue
Block a user