> But the manual doesn't say that it *only* removes slashes
> added by addslashes.

"Returns a string with backslashes stripped off. (\' becomes ' and so on.) Double backslashes (\\) are made into a single backslash (\)."

Yes, it doesn't *say*, but i think anyone could see that implied if one didn't have previous knowledge of what it really does.

I understand it works exactly how its supposed to, but why is it supposed to work this way?
Inspired in something from another project?
Probably what I'm thinking as the right behavior, is what someone that hasn't put enough thought on it would think hehe
To sum up: why was the real way choosen?




Rasmus Lerdorf wrote:
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

Attachment: signature.asc
Description: OpenPGP digital signature



Reply via email to