Docker Security: Remove <script> and <iframe>

Recursively remove any <script> or <iframe> from all elements in a template
This commit is contained in:
Squidly271
2018-03-17 17:08:00 -04:00
committed by GitHub
parent 30dc063bb2
commit 79f4fce086
@@ -374,9 +374,27 @@ function xmlToVar($xml) {
}
}
}
xmlSecurity($out);
return $out;
}
function xmlSecurity(&$template) {
foreach ($template as &$element) {
if ( is_array($element) ) {
xmlSecurity($element);
} else {
if ( is_string($element) ) {
$tempElement = htmlspecialchars_decode($element);
$tempElement = str_replace("[","<",$tempElement);
$tempElement = str_replace("]",">",$tempElement);
if ( preg_match('#<script(.*?)>(.*?)</script>#is',$tempElement) || preg_match('#<iframe(.*?)>(.*?)</iframe>#is',$tempElement) ) {
$element = "REMOVED";
}
}
}
}
}
function xmlToCommand($xml, $create_paths=false) {
global $var;
global $docroot;