From:             john at web-imagineer dot com
Operating system: SunOS
PHP version:      4CVS-2004-05-27 (stable)
PHP Bug Type:     Strings related
Bug description:  mysql_escape_string adding a VISIBLE \0 to the end of a string

Description:
------------
this would probably make more immediate sense if you look at the code and
the output result first, but heres the basics..

this is weird....
1) i have a string: "10,11,12,13,14,"
2) i remove the final comma by doing 
$groupstr[strlen($groupstr)-1]="";
3) i now have "10,11,12,13,14"
4) heres the weird part...i do mysql_escape_string() on it and i get:
10,11,12,13,14\0

basically, a visible \0 what looks like it should be a null is added to
the end of the string.


Reproduce code:
---------------
<?
//This is really wacky (the mysql_escape_string output)
$groupstr="10,11,12,13,14,";
print $groupstr."<BR>"; 
$groupstr[strlen($groupstr)-1]="";
print $groupstr."<BR>"; 
print mysql_escape_string($groupstr);
                        
print "<BR><BR><BR>";

//This works fine                       
$groupstr="10,11,12,13,14,";
print $groupstr."<BR>"; 
$groupstr=substr($groupstr,0,strlen($groupstr)-1);
print $groupstr."<BR>"; 
print mysql_escape_string($groupstr);           
?>

Expected result:
----------------
10,11,12,13,14,
10,11,12,13,14
10,11,12,13,14


10,11,12,13,14,
10,11,12,13,14
10,11,12,13,14 

Actual result:
--------------
10,11,12,13,14,
10,11,12,13,14
10,11,12,13,14\0


10,11,12,13,14,
10,11,12,13,14
10,11,12,13,14 

-- 
Edit bug report at http://bugs.php.net/?id=28538&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28538&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28538&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28538&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28538&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28538&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28538&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28538&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28538&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28538&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28538&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28538&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28538&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28538&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28538&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28538&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28538&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28538&r=float

Reply via email to