Skip to content

Commit 0cbe727

Browse files
committed
Merge branch '2.3' into 2.4
* 2.3: (34 commits) Fix #8205 : Deprecate file mode update when calling dumpFile Fix #10437: Catch exceptions when reloading a no-cache request Fix libxml_use_internal_errors and libxml_disable_entity_loader usage removed ini check to make uploadedfile work on gae Update OptionsResolver.php fixed comment in forms.xml file Clean KernelInterface docblocks Cast the group name as a string Fixed doc of InitAclCommand [Form] Fix "Array was modified outside object" in ResizeFormListener. Fix IBAN validator [Process] Remove unreachable code + avoid skipping tests in sigchild environment Fixed bug that incorrectly causes the "required" attribute to be omitted from select even though it contains the "multiple" attribute Added travis_retry to .travis.yml [Process] fix some typos and refactor some code [Process] Fix unit tests in sigchild disabled environment [Process] Trow exceptions in case a Process method is supposed to be called after termination fixed typo [Process] fixed fatal errors in getOutput and getErrorOutput when process was not started [Process] Fix escaping on Windows ... Conflicts: src/Symfony/Component/DomCrawler/Crawler.php src/Symfony/Component/Filesystem/Filesystem.php src/Symfony/Component/Process/Process.php
2 parents 5700c0f + a8054b9 commit 0cbe727

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Encoder/XmlEncoder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function encode($data, $format, array $context = array())
6868
*/
6969
public function decode($data, $format, array $context = array())
7070
{
71+
if ('' === trim($data)) {
72+
throw new UnexpectedValueException('Invalid XML data, it can not be empty.');
73+
}
74+
7175
$internalErrors = libxml_use_internal_errors(true);
7276
$disableEntities = libxml_disable_entity_loader(true);
7377
libxml_clear_errors();
@@ -79,6 +83,8 @@ public function decode($data, $format, array $context = array())
7983
libxml_disable_entity_loader($disableEntities);
8084

8185
if ($error = libxml_get_last_error()) {
86+
libxml_clear_errors();
87+
8288
throw new UnexpectedValueException($error->message);
8389
}
8490

Tests/Encoder/XmlEncoderTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,12 @@ public function testPreventsComplexExternalEntities()
347347
}
348348
}
349349

350+
public function testDecodeEmptyXml()
351+
{
352+
$this->setExpectedException('Symfony\Component\Serializer\Exception\UnexpectedValueException', 'Invalid XML data, it can not be empty.');
353+
$this->encoder->decode(' ', 'xml');
354+
}
355+
350356
protected function getXmlSource()
351357
{
352358
return '<?xml version="1.0"?>'."\n".

0 commit comments

Comments
 (0)