Skip to content

Commit

Permalink
Url could contain Javascript that leeds to XSS #1159
Browse files Browse the repository at this point in the history
  • Loading branch information
Fasse committed Jan 8, 2022
1 parent 5720147 commit d86f980
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions adm_program/system/classes/StringUtils.php
Expand Up @@ -182,8 +182,8 @@ public static function strValidCharacters($string, $checkType)
$validRegex = '=^[^/?*;:~<>|\"\\\\]+$=';
break;
case 'url':
//$validRegex = '/^[\wáàâåäæçéèêîñóòôöõøœúùûüß$&!?() \/%=#:~.@+-]+$/i';
$validRegex = '/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i';
$validRegex = '/^[\wáàâåäæçéèêîñóòôöõøœúùûüß$&!?() \/%=#:~.@+-]+$/i';
$validRegexValidUrl = '/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i';
break;
case 'phone':
$validRegex = '/^[\d() \/+-]+$/i';
Expand All @@ -203,6 +203,11 @@ public static function strValidCharacters($string, $checkType)
case 'email':
return filter_var(trim($string), FILTER_VALIDATE_EMAIL) !== false;
case 'url':
// url has a valid structure
if (!preg_match($validRegexValidUrl, $string)) {
return false;
}

return filter_var(trim($string), FILTER_VALIDATE_URL) !== false;
default:
return true;
Expand Down

0 comments on commit d86f980

Please sign in to comment.