Skip to content

Commit

Permalink
prevents injection of malicious doc types
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Aug 28, 2012
1 parent ccd8a86 commit cb3439f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Loader/XliffFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ private function parseFile($file)
throw new \RuntimeException(implode("\n", $this->getXmlErrors($internalErrors)));
}

foreach ($dom->childNodes as $child) {
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
libxml_use_internal_errors($internalErrors);

throw new \RuntimeException('Document types are not allowed.');
}
}

$location = str_replace('\\', '/', __DIR__).'/schema/dic/xliff-core/xml.xsd';
$parts = explode('/', $location);
if (0 === stripos($location, 'phar://')) {
Expand Down

0 comments on commit cb3439f

Please sign in to comment.