#34477 [NEW]: strtok() treats repeat of characters as single occurance

From: Date: Mon, 12 Sep 2005 08:16:23 +0000
Subject: #34477 [NEW]: strtok() treats repeat of characters as single occurance
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-84908@lists.php.net to get a copy of this message
From: black at scene-si dot org Operating system: linux deb PHP version: 4.4.0 PHP Bug Type: Strings related Bug description: strtok() treats repeat of characters as single occurance Description: ------------ strtok() ignores repeats of "arg2" ie. needle, and treats it as a single occurance, skipping all repetitions Reproduce code: --------------- $query = "wtf ? omg ? wtf ???, ?"; $arguments = array(1,2,3,4,5,6); var_dump($query); $sql = strtok($query,"?"); var_dump($sql); $retval = ""; while ($sql!==false) { $wasempty = empty($arguments); $val = array_shift($arguments); $retval .= $sql; if (!is_null($val) || !$wasempty) { $retval .= "'".$this->escape($val).'\''; } $sql = strtok("?"); var_dump($sql); } echo $retval; Expected result: ---------------- string(22) "wtf ? omg ? wtf ???, ?" string(4) "wtf " string(5) " omg " string(5) " wtf " string(0) "" string(0) "" string(2) ", " bool(false) wtf '1' omg '2' wtf '3''4''5', '6' Actual result: -------------- string(22) "wtf ? omg ? wtf ???, ?" string(4) "wtf " string(5) " omg " string(5) " wtf " string(2) ", " bool(false) wtf '1' omg '2' wtf '3', '4' -- Edit bug report at http://bugs.php.net/?id=34477&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34477&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34477&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34477&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34477&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34477&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34477&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34477&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34477&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34477&r=support Expected behavior: http://bugs.php.net/fix.php?id=34477&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34477&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34477&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34477&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34477&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34477&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34477&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34477&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34477&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34477&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34477&r=mysqlcfg

« previous php.bugs (#84908) next »