Announcement

Collapse
No announcement yet.

Username Regular Expression: regexp doesn't work, strange code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Forum] Username Regular Expression: regexp doesn't work, strange code

    Hi,

    I'm trying to use the Username Regular Expression option at registration. And I got strange errors, regex that are valid and usable in PHP but not in vB (using 4.1.3).

    So, I looked at the code. I'm no specialist, but I find it strange, first of all by not using preg_match at all. It seems the vB code for this check is:

    PHP Code:
            else if (!empty($this->registry->options['illegalusernames']))
            {
                
    // check for illegal username
                
    $usernames preg_split('/[ \r\n\t]+/'$this->registry->options['illegalusernames'], -1PREG_SPLIT_NO_EMPTY);
                foreach (
    $usernames AS $val)
                {
                    if (
    strpos(strtolower($username), strtolower($val)) !== false)
                    {
                        
    // wierd error to show, but hey...
                        
    $this->error('usernametaken'htmlspecialchars_uni($username), $this->registry->session->vars['sessionurl']);
                        return 
    false;
                    }
                }
            } 
    And for example,

    Code:
    ^([A-Za-zàâäÀÂÄéèêëÈÊûüùÜîïç\-\s]|_([A-Za-zàâäÀÂÄéèêëÈÊûüùÜîïç\-\s]|$))([A-Za-zàâäÀÂÄéèêëÈÊûüùÜîïç\-\s]|_([A-Za-zàâäÀÂÄéèêëÈÊûüùÜîïç\-\s]|$))$
    doesn't work (vB says anything is an illegal username). I've tested other variant, very simple regex seems to work but anything somewhat less basic choke.

    Anyone got an idea?

  • #2
    I ran that regex though regex buddy and nothing after the first two characters matches, ever. The first two characters however always match.

    Comment

    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
    Working...
    X