Re: stripslashes() improvements

From: Date: Thu, 10 Jun 2004 15:02:47 +0000
Subject: Re: stripslashes() improvements
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-10387@lists.php.net to get a copy of this message
On Thu, 10 Jun 2004, Andre Cerqueira wrote: > The 2 first bugs where really bogus, but imho the last one did make sense. > > If stripslashes does "Un-quote string quoted with addslashes()", how > addslashes would come up with: > > c:\windows\system32 > from: > > c:windowssystem32 It can't! How would it? Nobody has ever stated that addslashes() can undo a stripslashes() call. That's like expecting there to be an untrim() call to match trim(), for example. > a) stripslashes() were meant to strip all slashes > This confused me, probably i misinterpreted... > Wouldnt it be like calling strtr($string, '\\', '')? Not quite, stripslashes() understands the sybase style of escaping ('') and it is faster than strtr for that case. > b) stripslashes() were meant to strip all slashes but the ones followed > by a slash (if any) > This is how it works now > Though it makes (stripslashes(addslashes(string)) == string) true, it > doesnt make (addslashes(stripslashes(string)) == string) necessarily true. Correct. The goal of stripslashes() was simply to get rid of the set of slashes added by magic_quotes for display purposes and it achieves this quite nicely. > c) stripslashes() were meant to strip all slashes added by addslashes > This is what the manual says. And it does. But the manual doesn't say that it *only* removes slashes added by addslashes. -Rasmus

« previous php.internals (#10387) next »