ID:               44876
 User updated by:  c dot onogol at gmail dot com
 Reported By:      c dot onogol at gmail dot com
 Status:           Wont fix
 Bug Type:         Scripting Engine problem
 Operating System: Windows NT
 PHP Version:      5.2.5
 New Comment:

According to the documentation, stripslashes() un-quotes strings quoted
with addslashes().
The slash in the example would have never been added by addslashes()
and is not escaping any quotes or backslashes.


If this is the expected behavior, then one could say the documentation
is inaccurate and misleading.

Under return values it even says:
"Returns a string with backslashes stripped off. (\' becomes ' and so
on.) Double backslashes (\\) are made into a single backslash (\)."

I think the expected behavior one gets from the documentation differs
from the actual behavior of the function. Something along the lines of
"strips all backslashes" would be more accurate if the expected behavior
is the one you describe


Thanks


Previous Comments:
------------------------------------------------------------------------

[2008-05-02 20:32:42] [EMAIL PROTECTED]

This is expected behaviour and has always been this way.

------------------------------------------------------------------------

[2008-04-30 21:16:17] c dot onogol at gmail dot com

Description:
------------
stripslashes is supposed to remove backslashes added by addslashes():
from the doc:
   stripslashes — Un-quote string quoted with addslashes()
   addslashes — Quote string with slashes


stripslashes return values from the documentation:
Returns a string with backslashes stripped off. (\' becomes ' and so
on.) Double backslashes (\\) are made into a single backslash (\).

The problem is that it removes single backslashes that are not escaping
any quotes/slashes.
For example, "this one \ that one" should stay the same after running
stripslashes(), but it actually is stripping the backslash, so the end
result of stripslashes("this one \ that one") is "this one that one".

the backslash in "this one \ that one" is part of the original text and
is not a backslash addslashes() would add.










Reproduce code:
---------------
<?
$str = "this one \ should stay. it\'s a \"test\"";
$str = stripslashes($str);
var_dump($str);
?>

Expected result:
----------------
string(37) "this one \ should stay. it's a "test""

Actual result:
--------------
string(36) "this one should stay. it's a "test""


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44876&edit=1

Reply via email to