From: Andrei Zmievski Date: Wed, 9 Aug 2006 17:40:21 +0000 (+0000) Subject: addcslashes() and stripcslashes() should work only on binary strings. X-Git-Tag: RELEASE_1_0_0RC1~2005 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=533196671f54f0e4946e2fdce6a374e04faff839;p=php addcslashes() and stripcslashes() should work only on binary strings. --- diff --git a/ext/standard/string.c b/ext/standard/string.c index 8f3448c1a9..4044b3c048 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -4360,31 +4360,28 @@ PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC) } /* }}} */ -/* {{{ proto string addcslashes(string str, string charlist) +/* {{{ proto binary addcslashes(binary str, binary charlist) U Escapes all chars mentioned in charlist with backslash. It creates octal representations if asked to backslash characters with 8th bit set or with ASCII<32 (except '\n', '\r', '\t' etc...) */ PHP_FUNCTION(addcslashes) { - zval **str, **what; + char *str, *what; + int str_len, what_len; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &str, &what) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_DC, "SS", &str, &str_len, + &what, &what_len) == FAILURE) { + return; } - convert_to_string_ex(str); - convert_to_string_ex(what); - if (Z_STRLEN_PP(str) == 0) { + if (str_len == 0) { RETURN_EMPTY_STRING(); } - if (Z_STRLEN_PP(what) == 0) { - RETURN_STRINGL(Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1); + if (what_len == 0) { + RETURN_STRINGL(str, str_len, 1); } - RETURN_STRING(php_addcslashes(Z_STRVAL_PP(str), - Z_STRLEN_PP(str), - &Z_STRLEN_P(return_value), 0, - Z_STRVAL_PP(what), - Z_STRLEN_PP(what) TSRMLS_CC), 0); + RETURN_STRING(php_addcslashes(str, str_len, &Z_STRLEN_P(return_value), 0, + what, what_len TSRMLS_CC), 0); } /* }}} */ @@ -4419,18 +4416,18 @@ PHP_FUNCTION(addslashes) } /* }}} */ -/* {{{ proto string stripcslashes(string str) +/* {{{ proto binary stripcslashes(binary str) U Strips backslashes from a string. Uses C-style conventions */ PHP_FUNCTION(stripcslashes) { - zval **str; + char *str; + int str_len; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_DC, "S", &str, &str_len) == FAILURE) { + return; } - convert_to_string_ex(str); - ZVAL_STRINGL(return_value, Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1); + ZVAL_STRINGL(return_value, str, str_len, 1); php_stripcslashes(Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value)); } /* }}} */ @@ -5362,7 +5359,6 @@ PHP_FUNCTION(hebrevc) } /* }}} */ - /* {{{ proto string nl2br(string str) U Converts newlines to HTML line breaks */ PHP_FUNCTION(nl2br) @@ -5487,7 +5483,6 @@ PHP_FUNCTION(nl2br) } /* }}} */ - /* {{{ proto string strip_tags(string str [, string allowable_tags]) U Strips HTML and PHP tags from a string */ PHP_FUNCTION(strip_tags) diff --git a/unicode-progress.txt b/unicode-progress.txt index 8ce7457b31..5e0fa20fc6 100644 --- a/unicode-progress.txt +++ b/unicode-progress.txt @@ -16,9 +16,6 @@ ext/standard string.c -------- - addcslashes() - Params API. Figure out how to escape characters > 255. - chunk_split() Params API, Unicode upgrades. Split on codepoint level. @@ -70,9 +67,6 @@ ext/standard strcoll() Params API, upgrade to use Collator if TT == IS_UNICODE, test - stripcslashes() - Params API. Depends on how addcslashes() is implemented. - stristr() This is the problematic one. There are a few approaches: @@ -186,6 +180,7 @@ ext/standard string.c -------- + addcslashes() addslashes() basename() bin2hex() @@ -203,6 +198,7 @@ ext/standard str_repeat() strcspn() strip_tags() + stripcslashes() stripslashes() strpbrk() strpos()