]> granicus.if.org Git - php/commitdiff
Fixed stripslashes when magic_quotes_sybase is enabled, and add a test for
authorSander Roobol <sander@php.net>
Tue, 18 Jun 2002 11:51:06 +0000 (11:51 +0000)
committerSander Roobol <sander@php.net>
Tue, 18 Jun 2002 11:51:06 +0000 (11:51 +0000)
add- and stripslashes().
# this time without cvs messing up and aborting, hopefully :)

ext/standard/string.c
ext/standard/tests/strings/add-and-stripslashes.phpt

index 1945d87a15877be03b0d299c2510497620071094..0c4fabb710ba2f9d3dda83006ce058bb0bf2467d 100644 (file)
@@ -2133,8 +2133,6 @@ PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC)
 {
        char *s, *t;
        int l;
-       char escape_char='\\';
-
 
        if (len != NULL) {
                l = *len;
@@ -2153,8 +2151,16 @@ PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC)
                                                (*len)--;
                                        l--;
                                }
-                       } 
-                       *s++ = *t++;
+                               *s++ = *t++;
+                       } else if (*t=='\\' && l>0 && t[1]=='0') {
+                                       *s++='\0';
+                                       t += 2;
+                                       if (len != NULL) 
+                                               (*len)--;
+                                       l--;
+                       } else {
+                               *s++ = *t++;
+                       }
                        l--;
                }
                *s = '\0';
@@ -2163,7 +2169,7 @@ PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC)
        }
 
        while (l > 0) {
-               if (*t == escape_char) {
+               if (*t == '\\') {
                        t++;                            /* skip the slash */
                        if (len != NULL)
                                (*len)--;
index bc0a96b8c1eaa3516d079bc6cf957fefbc03534f..1c65aefda6b85f77d003377435c5ed078765bbae 100644 (file)
@@ -15,7 +15,18 @@ ini_set('magic_quotes_sybase', 0);
 if($input === stripslashes(addslashes($input))) {
        echo "OK\n";
 } else {
-       echo "FAILE                     right_nimized case to avoid callOK\n";
+       echo "FAILED\n";
+}
+
+echo "Sybase: ";
+ini_set('magic_quotes_sybase', 1);
+if($input === stripslashes(addslashes($input))) {
+       echo "OK\n";
 } else {
-       echo "FAILE                     right_nimizeding ni-hr= php_name(TSRMLS_C).= Pymbol",  ;i<lenusing 'nacalgorithm */
-PHP_FUNCTION(strnatcesult) {RONG} eTRLEN_
\ No newline at end of file
+       echo "FAILED\n";
+}
+
+?>
+--EXPECT--
+Normal: OK
+Sybase: OK