|
@@ -53,6 +53,15 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->assertEquals($expected, $this->encoder->encode($obj, 'xml'));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @expectedException \InvalidArgumentException
|
|
|
+ * @expectedExceptionMessage Document types are not allowed.
|
|
|
+ */
|
|
|
+ public function testDocTypeIsNotAllowed()
|
|
|
+ {
|
|
|
+ $this->encoder->decode('<?xml version="1.0"?><!DOCTYPE foo><foo></foo>', 'foo');
|
|
|
+ }
|
|
|
+
|
|
|
public function testAttributes()
|
|
|
{
|
|
|
$obj = new ScalarDummy;
|
|
@@ -233,20 +242,22 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @expectedException Symfony\Component\Serializer\Exception\UnexpectedValueException
|
|
|
- */
|
|
|
public function testPreventsComplexExternalEntities()
|
|
|
{
|
|
|
$oldCwd = getcwd();
|
|
|
chdir(__DIR__);
|
|
|
|
|
|
try {
|
|
|
- $decoded = $this->encoder->decode('<?xml version="1.0"?><!DOCTYPE scan[<!ENTITY test SYSTEM "php://filter/read=convert.base64-encode/resource=XmlEncoderTest.php">]><scan>&test;</scan>', 'xml');
|
|
|
+ $this->encoder->decode('<?xml version="1.0"?><!DOCTYPE scan[<!ENTITY test SYSTEM "php://filter/read=convert.base64-encode/resource=XmlEncoderTest.php">]><scan>&test;</scan>', 'xml');
|
|
|
chdir($oldCwd);
|
|
|
- } catch (UnexpectedValueException $e) {
|
|
|
+
|
|
|
+ $this->fail('No exception was thrown.');
|
|
|
+ } catch (\Exception $e) {
|
|
|
chdir($oldCwd);
|
|
|
- throw $e;
|
|
|
+
|
|
|
+ if (!$e instanceof \InvalidArgumentException) {
|
|
|
+ $this->fail('Expected InvalidArgumentException');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|