Skip to content

Instantly share code, notes, and snippets.

@padraic
Created August 14, 2012 18:25
Show Gist options
  • Save padraic/3351487 to your computer and use it in GitHub Desktop.
Save padraic/3351487 to your computer and use it in GitHub Desktop.
xee defense
<?php
$dom = new DOMDocument;
$dom->loadXML($xml);
foreach ($dom->childNodes as $child) {
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
throw new \InvalidArgumentException(
'Invalid XML: Detected use of illegal DOCTYPE'
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment