How to block special charakters in username? How to block special charakters in username?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

How to block special charakters in username?

Started by pawelfoto, December 15, 2009, 09:41:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pawelfoto

Hello,


I have a problem with the users whose names contain special  and unusual characters like:  , ą, ó, ł and underscore.

Problem is, because username is passing to some script, and that script does not recognize these characters.

It is possible to rework scirpt so as to block these characters?



pawelfoto

Sorry, i am absentminded.  I would like block it on registration page - register.php

Joachim Müller

Quote from: pawelfoto on December 15, 2009, 09:44:13 PM
I would like block it on registration page - register.php
Edit register.php, find function check_user_info(&$error)and add your custom validation code, e.g. afterif (utf_strlen($user_name) < 2) $error .= '<li>' . $lang_register_php['err_uname_short'];in a new line you might add something likeif (!eregi("^[0-9a-zA-Z]$", $user_name)) $error .= '<li>Illegal character in username' ;

Quote from: pawelfoto on December 15, 2009, 09:41:40 PMProblem is, because username is passing to some script, and that script does not recognize these characters.
Better option: edit that other script to allow special characters.

pawelfoto

 Hi
There is somethong wrong .. :-[

after adding the lines of code are blocked all the characters... Even if I want to register a user "abcd"  I gets message - Illegal character in username.

VEGA

if (!eregi("^[*-@-:-']$", $user_name)) $error .= '<li>Illegal character in username' ;

I included the characters that do not want them to be used for register. Not know if I can help you!

pawelfoto

Quote from: VEGA on December 16, 2009, 04:27:26 PM
if (!eregi("^[*-@-:-']$", $user_name)) $error .= '<li>Illegal character in username' ;

I included the characters that do not want them to be used for register. Not know if I can help you!

That's clever  :)

I need to check it.

Joachim Müller

Better to revert the logic by removing the exclamation mark: you probably haven't thought of all harmfull chracters. A whitelist is better than a blacklist in this aspect.

pawelfoto

Finally I made it in this way:
if (eregi("([^abcdefghijklmnopqrstuvwxyz0123456789])", $user_name)) $error .= '<li>Nieprawidłowy znak w nazwie użytkownika.' ;

This meets my expectations in 100%

phill104

It is a mistake to think you can solve any major problems just with potatoes.

Joachim Müller

...and what exactly is so different about your way? What's the use of if (eregi("([^abcdefghijklmnopqrstuvwxyz0123456789])", $user_name)) $error .= '<li>Nieprawidłowy znak w nazwie użytkownika.' ;in comparison toif (eregi("([^a-z0-9])", $user_name)) $error .= '<li>Nieprawidłowy znak w nazwie użytkownika.' ;