Skip to content

Commit

Permalink
Additional xss improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlawrence committed Aug 13, 2015
1 parent d4fd9a2 commit 4a1acde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,10 @@ function xss_clean($str)
$str = preg_replace('#</*\w+:\w[^>]*+>#i', '', $str);

// Remove any attempts to pass-in a script tag obfuscated by spaces
$str = preg_replace('/<\s+s\s+c\s+r\s+i\s+p\s+t/', '', $str);
$str = preg_replace('#<\s?/?\s*[Ss]\s*[cC]\s*[rR]\s*[iI]\s*[pP]\s*[tT]#', '', $str);

// Removed ;base64 data usage
$str = preg_replace('#data:*[^;]+;base64,#', 'nodatabase64', $str);

do {
// Remove really unwanted tags
Expand All @@ -860,7 +863,7 @@ function redirect_visitor($url = '')
} else {
// Lets make sure its not an outside URL
if (!preg_match('#^(http|https|ftp)://#', $url)) {
header('Location:' . $url);
header('Location:' . htmlentities($url, ENT_QUOTES));
exit;
} else {
header('Location:index.php');
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
} elseif (!isset($_POST['login']) && $GLOBALS['CONFIG']['authen'] == 'mysql') {
$redirection = (isset($_REQUEST['redirection']) ? $_REQUEST['redirection'] : '');

$GLOBALS['smarty']->assign('redirection', $redirection);
$GLOBALS['smarty']->assign('redirection', htmlentities($redirection, ENT_QUOTES));
display_smarty_template('login.tpl');
} else {
echo 'Check your config';
Expand Down

0 comments on commit 4a1acde

Please sign in to comment.