From ace4a23dfcf7a812b25d03638971b330c486d2a2 Mon Sep 17 00:00:00 2001 From: Sander Roobol Date: Tue, 18 Jun 2002 11:51:06 +0000 Subject: [PATCH] Fixed stripslashes when magic_quotes_sybase is enabled, and add a test for add- and stripslashes(). # this time without cvs messing up and aborting, hopefully :) --- ext/standard/string.c | 16 +++++++++++----- .../tests/strings/add-and-stripslashes.phpt | 17 ++++++++++++++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ext/standard/string.c b/ext/standard/string.c index 1945d87a15..0c4fabb710 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -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)--; diff --git a/ext/standard/tests/strings/add-and-stripslashes.phpt b/ext/standard/tests/strings/add-and-stripslashes.phpt index bc0a96b8c1..1c65aefda6 100644 --- a/ext/standard/tests/strings/add-and-stripslashes.phpt +++ b/ext/standard/tests/strings/add-and-stripslashes.phpt @@ -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 +--EXPECT-- +Normal: OK +Sybase: OK -- 2.50.1