Skip to content

Commit 6292442

Browse files
committed
Add unit test
1 parent 6540d61 commit 6292442

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/XML/DOMDocumentFactoryTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ public function testStringThatContainsDocTypeIsNotAccepted(): void
8484
}
8585

8686

87+
public function testStringThatContainsDocTypeIsNotAccepted2(): void
88+
{
89+
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>
90+
<!DOCTYPE foo [<!ENTITY % exfiltrate SYSTEM "file://dev/random">%exfiltrate;]>
91+
<foo>y</foo>';
92+
$this->expectException(RuntimeException::class);
93+
$this->expectExceptionMessage(
94+
'Dangerous XML detected, DOCTYPE nodes are not allowed in the XML body',
95+
);
96+
DOMDocumentFactory::fromString($xml);
97+
}
98+
99+
87100
public function testEmptyFileIsNotValid(): void
88101
{
89102
$file = 'resources/xml/domdocument_empty.xml';

0 commit comments

Comments
 (0)