Bug #13866: strtok() parses erroneously empty substrings - PHP 4.0.7RC2
| From: | rcpj at panix dot com | Date: | Mon, 29 Oct 2001 22:32:57 +0000 |
| Subject: | Bug #13866: strtok() parses erroneously empty substrings - PHP 4.0.7RC2 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-69303@lists.php.net to get a copy of this message | ||
From: rcpj@panix.com
Operating system: Linux
PHP version: 4.0.6
PHP Bug Type: Strings related
Bug description: strtok() parses erroneously empty substrings - PHP 4.0.7RC2
NOTE, the PHP version is reported as 4.0.7RC2 but that's not in the
predefined list on the form.
------
The function strtok() misparses strings where some fields are empty, such
as #1 and #4 in the list below,
1|carrot||(no adjective)
2|pepper|red|(adjective)
3|pepper|green|(adjective)
4|tomato||(no adjective)
5|apricot|dried|(adjective)
Compare the output of the test program (the code is listed below) running
(under PHP 4.0.7RC2) at:
http://www.web-ho.com/PHP/test-module.php
versus the same program (under PHP 4.0.3pl1) at:
http://www.pierrejelenc.com/PHP/test-module.php
Both the Apache module and the CGI version in /usr/local/bin/php are
affected.
============== test-module.php =============
<?php
$Item=file("test-data");
for ($i=0; $i<count($Item);$i++)
{
$Number=strtok(chop($Item[$i]),"|");
$Name=strtok("|");
$Type=strtok("|");
$Comment=strtok("|");
print("$Type $Name: line #$Number $Comment<br>\n");
}
?>
</body></html>
===========================================
I am not in charge of program maintenance on either system, but I am the
webmaster for several sites there. I was encouraged by the administrator of
the machine on which web-ho.com is located to report this myself.
Cheers,
Pierre Jelenc
rcpj@panix.com
--
Edit bug report at: http://bugs.php.net/?id=13866&edit=1