ID: 27848 Updated by: [EMAIL PROTECTED] Reported By: spam at pasher dot org -Status: Feedback +Status: Bogus Bug Type: Strings related Operating System: Debian (Linux 2.4.18-bf2.4) PHP Version: 4.3.4 New Comment:
read above. Previous Comments: ------------------------------------------------------------------------ [2004-04-04 13:51:12] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Here is a proof why it works: ?php $a = "test\\"; $b = addslashes($a); $c = stripslashes($b); var_dump($a === $c); ?> ------------------------------------------------------------------------ [2004-04-03 15:09:50] spam at pasher dot org I don't think you quite understand the reasoning I am giving. I understand that the \\ gets converted in the string to \. The problem is the following string this is a test\ ends up becoming this is a test after a run through stripslashes. Where is the logic in stripslashes stripping out ANY slash that it finds, instead of only stripping out slashes that are used to backslash another character? According to the documentation, the purpose of stripslashes is the following: "Un-quote string quoted with addslashes()" Why would stripslashes remove a trailing \ when there is NO way the addslashes() function would ever produce a string that ends in a single trailing \ ? This appears to be a logic error (or really an over-assumption) on the part of stripslashes(). ------------------------------------------------------------------------ [2004-04-03 13:15:57] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php When you create the string \\ gets converted to \, which is why the slash gets stripped by stripslashes(). ------------------------------------------------------------------------ [2004-04-02 20:50:23] spam at pasher dot org Description: ------------ The stripslashes() function strips off a single trailing \ when altering a string. I can see that according to bug report http://bugs.php.net/bug.php?id=19947 , this function is not supposed to be an exact opposite of addslashes(), but it seems as thought a string that ends in a single \ should not have that slash removed, as the slash is not actually backslashing any part of the string. The only reasoning I could see behind this is that either any slash is stripped by stripslashes, or the \0 stored at the end of the C code string to terminate it (but not actually part of the PHP code string) is considered a character being "escaped". If stripslashes() is designed to simple strip any slash from a string, it seems like the design should be rethought a bit, as it can potentially produced undesired results. Reproduce code: --------------- <? echo stripslashes("this is a test\\"); ?> Expected result: ---------------- Displays "this is a test\" Actual result: -------------- Displays "this is a test" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27848&edit=1