Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: How to block special charakters in username?  (Read 4475 times)

0 Members and 1 Guest are viewing this topic.

pawelfoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 22
How to block special charakters in username?
« on: December 15, 2009, 09:41:40 pm »

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?

Logged

pawelfoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 22
Re: How to block special charakters in username?
« Reply #1 on: December 15, 2009, 09:42:19 pm »

Logged

pawelfoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 22
Re: How to block special charakters in username?
« Reply #2 on: December 15, 2009, 09:44:13 pm »

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

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: How to block special charakters in username?
« Reply #3 on: December 16, 2009, 08:43:04 am »

I would like block it on registration page - register.php
Edit register.php, find
Code: [Select]
function check_user_info(&$error)and add your custom validation code, e.g. after
Code: [Select]
if (utf_strlen($user_name) < 2) $error .= '<li>' . $lang_register_php['err_uname_short'];in a new line you might add something like
Code: [Select]
if (!eregi("^[0-9a-zA-Z]$", $user_name)) $error .= '<li>Illegal character in username' ;
Problem 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.
Logged

pawelfoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 22
Re: How to block special charakters in username?
« Reply #4 on: December 16, 2009, 10:59:26 am »

 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.
Logged

VEGA

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 323
    • maranimage
Re: How to block special charakters in username?
« Reply #5 on: December 16, 2009, 04:27:26 pm »

Code: [Select]
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!
Logged

pawelfoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 22
Re: How to block special charakters in username?
« Reply #6 on: December 16, 2009, 04:43:18 pm »

Code: [Select]
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.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: How to block special charakters in username?
« Reply #7 on: December 16, 2009, 05:53:08 pm »

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.
Logged

pawelfoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 22
Re: How to block special charakters in username?
« Reply #8 on: December 16, 2009, 06:29:49 pm »

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

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
    • Windsurf.me
Logged
It is a mistake to think you can solve any major problems just with potatoes.

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: How to block special charakters in username?
« Reply #10 on: December 17, 2009, 07:35:15 am »

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

Page created in 0.028 seconds with 19 queries.