ID: 16123
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Closed
Bug Type: Strings related
Operating System: Windows 2K Server / IIS5
PHP Version: 4.1.2
New Comment:
OK. I'll get back to my book and try it differently.
Thanks for your help.
Previous Comments:
------------------------------------------------------------------------
[2002-03-17 04:55:00] [EMAIL PROTECTED]
The (old) behaviour of strtok() was broken and has been fixed which
effectively means the behaviour of strtok() has changed.
You may want to consider using explode() or split() instead of
strtok().
------------------------------------------------------------------------
[2002-03-17 04:46:41] [EMAIL PROTECTED]
(I'm not a PHP expert, so please be patient! :)
I'm crudely checking user login details to authenticate users on my
homepage. It's not great but it's been working in PHP4.0.6 for months.
After upgrading to 4.1.2 this script no longer works. Reinstalling
4.0.6 fixes the problem.
My stored string of user/password pairs:
============================
$userlist = "+name1>password1+name2>password2+name3....";
============================
$uname and $upass are POSTed to a script, and the following code is
part of a function called to check that the user/password pair exists
within $userlist.
Assume user enters their username "name2".
I validate the username in PHP4.0.6 with:
============================
$userfound = strstr($userlist, "+".$uname.">" );
// Correctly gives me $userfound == "+name2>password2+name3...."
if ($userfound)
{ // username found; get password
$delims = "+>";
strtok($userfound, $delims); // extract the user/password pair
$storedname = strtok($delims);
$storedpass = strtok($delims);
============================
...and in PHP4.0.6 I get (as you might expect) $storedname == "name2"
and $storedpass == "password2".
However, after upgrading to 4.1.2 (and everything else staying the
same) my parsed strings become $storedname == "password2" and
$storedpass == "name3". It doesn't matter whether there's additional
text before the first delimiting "+".
I'm stumped! It looks like a bug to me, and I've searched the bug list
for other strtok bugs, but none is the same as this.
Cheers,
Ben Harvey
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16123&edit=1