Skip to content

Commit 6540d61

Browse files
committed
Defense in depth: test for DOCTYPE in two different ways
1 parent 5ed85a4 commit 6540d61

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/DOMDocumentFactory.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ public static function fromString(string $xml): DOMDocument
6363

6464
libxml_clear_errors();
6565

66+
foreach ($domDocument->childNodes as $child) {
67+
Assert::false(
68+
$child->nodeType === XML_DOCUMENT_TYPE_NODE,
69+
'Dangerous XML detected, DOCTYPE nodes are not allowed in the XML body',
70+
RuntimeException::class,
71+
);
72+
}
73+
6674
return $domDocument;
6775
}
6876

0 commit comments

Comments
 (0)