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 :)
This commit is contained in:
Sander Roobol 2002-06-18 11:51:06 +00:00
parent 07975157eb
commit ace4a23dfc
2 changed files with 25 additions and 8 deletions

View 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)--;

View 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_
echo "FAILED\n";
}
?>
--EXPECT--
Normal: OK
Sybase: OK