Jump to content

Recommended Posts

Posted

First of all, its not a big problem.

I have created a custom registration form. For the username field I have used the sanatizer api before storing the username in the database.

$username is the variable from the form input after submit (Post)

I sanatize it like this:

$username = $sanitizer->username($username);

In the guidelines there is the following statement:

Sanitizes a value for a User name, meaning all characters except for these ASCII characters "a-zA-Z0-9-_.@" (not including the quotes) are removed. It also truncates the length to 50 characters.

So far so good, but sanatizing the username value changes all big letters [A-Z] to small letters [a-z]. So it doesnt allow big letters in the username. It is not a big deal, but big letters should be allowed according to the statement.

Does anyone made the same experience.

PS: I use the latest stable version of PW.

Addition: it also changes the "@" into "-" .

Posted

@deprecated, use pageName instead. This is since 2.4.

/**
 * Format required by ProcessWire user names
 *
 * @deprecated, use pageName instead.
 * @param string $value
 * @return string
 *
 */
public function username($value) {
    return $this->pageName($value); 
    /*
    $value = trim($value); 
    if(strlen($value) > 128) $value = substr($value, 0, 128); 
    if(ctype_alnum(str_replace(array('-', '_', '.', '@'), '', $value))) return $value; 
    return preg_replace('/[^-_.@a-zA-Z0-9]/', '_', trim($value)); 
    */
}
  • Like 1
Posted

Thanks Soma,

this was what I am looking for. Unfortunately there was no hint in the explaination of $sanitizer->username($value) that this is dpreceated in 2.4.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...