Recursively erase javascript URI scheme in noJSLink to avoid XSS

This commit is contained in:
Alejandro Romero Herrera 2020-08-31 12:27:49 +03:00
parent d5be0c0cdb
commit e2226c01e7

View file

@ -30,10 +30,14 @@ class Sanitize {
return htmlspecialchars_decode($text, $flags);
}
// Remove javacript from links
// Remove javascript from links
public static function noJSLink($text)
{
return preg_replace("/javascript\s*:\s*/", "", $text);
$text = trim($text);
while(strpos($text, 'javascript')===0){
$text = preg_replace("/javascript\s*:\s*/", "", $text);
}
return $text;
}
public static function pathFile($path, $file=false)