[support] getting the underscore to be unusable in user names
Earnie Boyd
earnie at users.sourceforge.net
Thu Aug 2 19:01:31 UTC 2007
Quoting Cog Rusty <cog.rusty at gmail.com>:
>
>> if (ereg("[^\x80-\xF7 [:alnum:]@_.-]", $name)) return t('The username
>> contains an illegal character.');
>>
>> seems to be disallowing @, underscore, period and hyphen...or is it allowing
>> them? Regular expressions were never my forte!
>
I don't think it is coded correctly. The range is 128-247 decimal
which in my day indicated control characters. So if $name contains
these or a space or alphanumeric or an @ or an _ or ANY CHARACTER (. is
a regular expression meta character meaning any character) or a - then
it will return the text message that username is invalid.
You need to character escape the period to make it useful. Maybe change it to
ereg("[\^\x80-\xF7 @_\.\-]", $name) would be useful.
>
> Neither mine. I think that one says that names can't begin (^) with
> these characters. In the absence of better advice, I would change
In researching I could only find ^ outside of the [] and I'm guessing
the range is limited to the first character of $name since it is inside
the [].
> something that I understand, for example I would copy and adapt the if
> (strpos($name, ' ') !== FALSE) line which checks for double spaces.
>
But you take away the fun of parsing the expression manually to
understand it. ;D. Joking aside, regular expressions are very useful
for this type of parsing. I was looking for a good tutorial on
extended regular expression patterns but didn't come up with one.
Earnie -- http://for-my-kids.com/
More information about the support
mailing list