[serializer] fixed whitespace issue when decoding xml
This commit is contained in:
parent
0a177805bc
commit
466a3d70b7
@ -77,7 +77,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
|
||||
libxml_clear_errors();
|
||||
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadXML($data, LIBXML_NONET);
|
||||
$dom->loadXML($data, LIBXML_NONET | LIBXML_NOBLANKS);
|
||||
|
||||
libxml_use_internal_errors($internalErrors);
|
||||
libxml_disable_entity_loader($disableEntities);
|
||||
|
@ -240,6 +240,19 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($expected, $this->encoder->decode($xml, 'xml'));
|
||||
}
|
||||
|
||||
public function testDecodeCdataWrappingAndWhitespace()
|
||||
{
|
||||
$expected = array(
|
||||
'firstname' => 'Paul <or Me>',
|
||||
);
|
||||
|
||||
$xml = '<?xml version="1.0"?>'."\n".
|
||||
'<response><firstname>'."\n".
|
||||
'<![CDATA[Paul <or Me>]]></firstname></response>'."\n";
|
||||
|
||||
$this->assertEquals($expected, $this->encoder->decode($xml, 'xml'));
|
||||
}
|
||||
|
||||
public function testDecodeScalarWithAttribute()
|
||||
{
|
||||
$source = '<?xml version="1.0"?>'."\n".
|
||||
|
Reference in New Issue
Block a user