File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ public function encode($data, $format)
54
54
*/
55
55
public function decode ($ data , $ format )
56
56
{
57
+ $ this ->assertNoCustomDocType ($ data );
57
58
$ internalErrors = libxml_use_internal_errors (true );
58
59
$ disableEntities = libxml_disable_entity_loader (true );
59
60
libxml_clear_errors ();
@@ -290,6 +291,17 @@ private function buildXml($parentNode, $data)
290
291
throw new UnexpectedValueException ('An unexpected value could not be serialized: ' .var_export ($ data , true ));
291
292
}
292
293
294
+ private function assertNoCustomDocType ($ data )
295
+ {
296
+ $ dom = new \DOMDocument ;
297
+ $ dom ->loadXML ($ data );
298
+ foreach ($ dom ->childNodes as $ child ) {
299
+ if ($ child ->nodeType === XML_DOCUMENT_TYPE_NODE ) {
300
+ throw new \InvalidArgumentException ('Document types are not allowed. ' );
301
+ }
302
+ }
303
+ }
304
+
293
305
/**
294
306
* Selects the type of node to create and appends it to the parent.
295
307
*
You can’t perform that action at this time.
0 commit comments