ID: 49146
Updated by: [email protected]
Reported By: juho dot karvilainen at bmf dot wz dot cz
Status: Bogus
Bug Type: Output Control
Operating System: Win XP
PHP Version: 5.2.10
New Comment:
Your array is also malformed.
array('"'=>'\"',"'">'\'','/'=>'\/')
array(3) {
["""]=>
string(2) "\""
[0]=>
bool(false)
["/"]=>
string(2) "\/"
}
Previous Comments:
------------------------------------------------------------------------
[2009-08-04 01:38:13] [email protected]
Closing PHP tags always eat the newline after it.
------------------------------------------------------------------------
[2009-08-04 01:36:45] juho dot karvilainen at bmf dot wz dot cz
Description:
------------
looks like the strtr() function (when used with array as 2nd argument)
nibbles a character from the end when it has nothing to replace. (on
UTF-8 page)
Reproduce code:
---------------
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?php
function safe_js($str){
return strtr($str,array('"'=>'\"',"'">'\'','/'=>'\/'));
}
?>
line1...<?php echo safe_js(480)?>
line2...
Expected result:
----------------
line1...480
line2
Actual result:
--------------
line1...48line2
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49146&edit=1