Skip to content

Commit 78856ce

Browse files
committed
Merge branch '2.3'
* 2.3: fixed CS fixed CS [HttpKernel] fixed memory limit display in MemoryDataCollector Fixed the error handling when decoding invalid XML to avoid a Warning [Form] Fixed: The "data" option is taken into account even if it is NULL [DomCrawler] [HttpFoundation] Make `Content-Type` attributes identification case-insensitive Conflicts: src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php
2 parents 6b7329f + 41fde9a commit 78856ce

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Encoder/XmlEncoder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public function decode($data, $format, array $context = array())
7878
libxml_use_internal_errors($internalErrors);
7979
libxml_disable_entity_loader($disableEntities);
8080

81+
if ($error = libxml_get_last_error()) {
82+
throw new UnexpectedValueException($error->message);
83+
}
84+
8185
foreach ($dom->childNodes as $child) {
8286
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
8387
throw new UnexpectedValueException('Document types are not allowed.');

Tests/Encoder/XmlEncoderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
class XmlEncoderTest extends \PHPUnit_Framework_TestCase
2222
{
23+
private $encoder;
24+
2325
protected function setUp()
2426
{
2527
$this->encoder = new XmlEncoder;
@@ -318,6 +320,14 @@ public function testDecodeWithoutItemHash()
318320
$this->assertEquals($expected, $this->encoder->decode($xml, 'xml'));
319321
}
320322

323+
/**
324+
* @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
325+
*/
326+
public function testDecodeInvalidXml()
327+
{
328+
$this->encoder->decode('<?xml version="1.0"?><invalid><xml>', 'xml');
329+
}
330+
321331
public function testPreventsComplexExternalEntities()
322332
{
323333
$oldCwd = getcwd();

0 commit comments

Comments
 (0)