Welcome, Guest. Please Login or Register.
November 08, 2024, 12:00:41 PM
Home Help Search Log in Register
News: If you are still using YaBB SE, please consider upgrading to SMF as soon as possible.

YaBB SE Community  |  English User Help  |  English Help  |  preg_match trouble « previous next »
Pages: [1] Reply Ignore Print
Author Topic: preg_match trouble  (Read 246 times)
Armadillo
Noobie
*
Posts: 22


Medieval Warrior

preg_match trouble
« on: April 20, 2003, 06:20:35 AM »
Reply with quote

I recently upgraded to 1.5.1 from 1.4.1. All files are uploaded and the board works fine.
Except, it still has a bug that caused me trouble in 1.4.1 (after PHP was upgraded to 4.3.0).
Some users (and me in tests) get an invalid character in username error when they log in. There are no illegal characters in the usernames.

I have found two things that I suspect.
Here is the code from Register.php....

if (!preg_match("/^[\s0-9A-Za-z#,-\.:=?@^_äöéèöüçåãâáàßêìíîïðñòóôõøùúûýÿ]+$/",$user))
fatal_error($txt[240]);

Here is the code from LogInOut.php....

if (!preg_match("/^[\s0-9A-Za-z#%+,-\.:=?@^_äöéèöüçåãâáàßêìíîïðñòóôõøùúûýÿ]+$/", $user))
fatal_error($txt[240]);

They both check the username for invalid characters, but they are not the same!
The code from LogInOut.php contains "%+" while the code from Register.php does not.
I suspect the code in LogInOut.php is causing the trouble. I dont know much about PHP, so I may be wrong.

Also, the pattern is in double quotes. Shouldn't it be in single quotes?

My question is, can I replace the code in LogInOut?
Or can I eliminate this code altogether?
Is it really necessary to check for all of those characters?


« Last Edit: April 20, 2003, 06:25:39 AM by Armadillo » Logged

Everything should be made as simple as possible, but no simpler.
[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:preg_match trouble
« Reply #1 on: April 20, 2003, 09:19:06 AM »
Reply with quote

Having these characters in usernames can cause problems.

You should probably be able to replace them both with:

if (!preg_match('/^[\s0-9A-Za-z#,\-\.:=?@^_äöéèöüçåãâáàßêìíîïðñòóôõøùúûýÿ]+$/',$user))
  fatal_error($txt[240]);

-[Unknown]
Logged
Armadillo
Noobie
*
Posts: 22


Medieval Warrior

Re:preg_match trouble
« Reply #2 on: April 21, 2003, 12:42:06 AM »
Reply with quote

Thanks. I'll give it a try.

The member names in question did not have any illegal charactors. Example- Major Glare

That name (and a few others) will be accepted by Register.php but not by LogInOut.php. Limiting the size of the username seems to help.

I suspect PHP 4.3.0 may be misinterpreting the code in LogInOut.php.
Logged

Everything should be made as simple as possible, but no simpler.
Armadillo
Noobie
*
Posts: 22


Medieval Warrior

Re:preg_match trouble
« Reply #3 on: April 21, 2003, 05:53:32 AM »
Reply with quote

Well, that wasn't it.
Both PHP scripts use the same preg_match code now (the one from [Unknown]) and it still does it.

The user names are all alpha characters and spaces. They are allowed to register, but when they log in they get the error message.
This seems to mainly effect some long names, so I have limited the length to 10 characters. I did the same thing with 1.4.1.

Anyone have any other ideas?
:'(
Logged

Everything should be made as simple as possible, but no simpler.
Pages: [1] Reply Ignore Print 
YaBB SE Community  |  English User Help  |  English Help  |  preg_match trouble « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 0.065 seconds with 21 queries.