ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-dev
php-dev
#44956 [Com]: stripslashes() removes slashes not added by addslashes()
by C Dot Onogol At Gmail Dot Com other posts by this author
May 9 2008 8:56AM messages near this date
#44956 [Com]: stripslashes() removes slashes not added by addslashes() | #44955 [NEW]: socket array keys not working as expected
ID:               44956
 Comment by:       c dot onogol at gmail dot com
 Reported By:      webmaster at drk dot com dot ar
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: Linux
 PHP Version:      5.2.6
 New Comment:

I agree.
The documentation makes you think it's the exact opposite of 
addslashes(), both in the function description and its return values 
(which happen to be explicitly listed, and there's no mention of 
removing single slashes that are not escaping anything).


There's no string that produces "this \ that" after a call to 
addslashes().


addslashes("this that") would never output "this \ that"...

The doc says clearly "Un-quotes a quoted string", it's clear its 
purpose is to run it on strings to be inserted in a DB, why would it 
remove single slashes?


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

[2008-05-09 15:43:35] webmaster at drk dot com dot ar

Description:
------------
stripslashes() removes slashes not added by addslashes()

I expect a function to do what is described in the first line of its
documentation. As published in this site "un-quotes strings quoted with
addslashes()"

It is water clear this functions isn't working as expected. As it
shouldn't remove any slash that addslashes() wouldn't add. In example, a
slash before a space won't be added by addslashes() and mustn't be
removed by stripslashes()

You can refuse to correct the code. In that case, which I consider most
useless, you ought to correct the documentation.

I ask myself won't be useful a function which undoes what addslashes()
does?

Reproduce code:
---------------
<?
$str = "the first \ should stay. it\'s the  \"right\" case";
$str = stripslashes($str);
var_dump($str);
?> 

Expected result:
----------------
"the first \ should stay. it's the  "right" case"

Actual result:
--------------
"the first  should stay. it's the  "right" case"


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


-- 
Edit this bug report at http://bugs.php.net/?id=44956&edit=1
Thread:
Webmaster At Drk Dot Com Dot Ar
C Dot Onogol At Gmail Dot Com
C Dot Onogol At Gmail Dot Com

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved