fixes #176, possible XSS in setup
This commit is contained in:
parent
2e7cac5c03
commit
5f23b4c2ea
@ -95,32 +95,37 @@ function getstep(&$id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validate() {
|
function validate() {
|
||||||
if (!ctype_alnum($_POST ['fpuser']))
|
$fpuser = strip_tags($_POST ['fpuser']);
|
||||||
$err [] = "{$_POST['fpuser']} is not a valid username.
|
$fppwd = $_POST ['fppwd'];
|
||||||
|
$fppwd2 = $_POST ['fppwd2'];
|
||||||
|
$email = strip_tags($_POST ['email']);
|
||||||
|
$www = strip_tags($_POST ['www']);
|
||||||
|
if (!ctype_alnum($fpuser)) {
|
||||||
|
$err [] = $fpuser . " is not a valid username.
|
||||||
Username must be alphanumeric and should not contain spaces.";
|
Username must be alphanumeric and should not contain spaces.";
|
||||||
|
}
|
||||||
if (strlen(trim(($_POST ['fppwd']))) < 6)
|
if (strlen(trim(($fppwd))) < 6) {
|
||||||
$err [] = "Password must contain at least 6 non-space characters";
|
$err [] = "Password must contain at least 6 non-space characters";
|
||||||
|
}
|
||||||
if (($_POST ['fppwd']) != ($_POST ['fppwd2']))
|
if (($fppwd) != ($fppwd2)) {
|
||||||
$err [] = "Passwords did not match";
|
$err [] = "Passwords did not match";
|
||||||
|
}
|
||||||
if (!(preg_match('!@.*@|\.\.|\,|\;!', $_POST ['email']) || preg_match('!^.+\@(\[?)[a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$!', $_POST ['email'])))
|
if (!(preg_match('!@.*@|\.\.|\,|\;!', $email) || preg_match('!^.+\@(\[?)[a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$!', $email))) {
|
||||||
$err [] = "{$_POST['email']} is not a valid email address";
|
$err [] = $email . " is not a valid email address";
|
||||||
|
}
|
||||||
$www = $_POST ['www'];
|
|
||||||
if (!(preg_match('!^http(s)?://[\w-]+\.[\w-]+(\S+)?$!i', $www) || preg_match('!^http(s)?://localhost!', $www)))
|
if (!(preg_match('!^http(s)?://[\w-]+\.[\w-]+(\S+)?$!i', $www) || preg_match('!^http(s)?://localhost!', $www)))
|
||||||
$err [] = "$www is not a valid URL";
|
$err [] = $www . " is not a valid URL";
|
||||||
if ($www && $www [strlen($www) - 1] != '/')
|
if ($www && $www [strlen($www) - 1] != '/') {
|
||||||
$www .= '/';
|
$www .= '/';
|
||||||
|
}
|
||||||
|
|
||||||
global $fp_config;
|
global $fp_config;
|
||||||
|
|
||||||
$fp_config ['general'] ['author'] = $user ['userid'] = $_POST ['fpuser'];
|
$fp_config ['general'] ['author'] = $user ['userid'] = $fpuser;
|
||||||
$user ['password'] = $_POST ['fppwd'];
|
$user ['password'] = $fppwd;
|
||||||
|
|
||||||
$fp_config ['general'] ['www'] = $user ['www'] = $www;
|
$fp_config ['general'] ['www'] = $user ['www'] = $www;
|
||||||
$fp_config ['general'] ['email'] = $user ['email'] = $_POST ['email'];
|
$fp_config ['general'] ['email'] = $user ['email'] = $email;
|
||||||
|
|
||||||
if (isset($err)) {
|
if (isset($err)) {
|
||||||
$GLOBALS ['err'] = $err;
|
$GLOBALS ['err'] = $err;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user