andrei          Wed Aug  9 17:40:22 2006 UTC

  Modified files:              
    /php-src    unicode-progress.txt 
    /php-src/ext/standard       string.c 
  Log:
  addcslashes() and stripcslashes() should work only on binary strings.
  
  
http://cvs.php.net/viewvc.cgi/php-src/unicode-progress.txt?r1=1.38&r2=1.39&diff_format=u
Index: php-src/unicode-progress.txt
diff -u php-src/unicode-progress.txt:1.38 php-src/unicode-progress.txt:1.39
--- php-src/unicode-progress.txt:1.38   Tue Aug  8 21:03:11 2006
+++ php-src/unicode-progress.txt        Wed Aug  9 17:40:21 2006
@@ -16,9 +16,6 @@
 
   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 @@
     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 @@
 
   string.c
   --------
+    addcslashes()
     addslashes()
     basename()
     bin2hex()
@@ -203,6 +198,7 @@
     str_repeat()
     strcspn()
     strip_tags()
+    stripcslashes()
     stripslashes()
     strpbrk()
     strpos()
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.568&r2=1.569&diff_format=u
Index: php-src/ext/standard/string.c
diff -u php-src/ext/standard/string.c:1.568 php-src/ext/standard/string.c:1.569
--- php-src/ext/standard/string.c:1.568 Tue Aug  8 22:01:48 2006
+++ php-src/ext/standard/string.c       Wed Aug  9 17:40:21 2006
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: string.c,v 1.568 2006/08/08 22:01:48 tony2001 Exp $ */
+/* $Id: string.c,v 1.569 2006/08/09 17:40:21 andrei Exp $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
@@ -4360,31 +4360,28 @@
 }
 /* }}} */
 
-/* {{{ 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 @@
 }
 /* }}} */
 
-/* {{{ 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 @@
 }
 /* }}} */
 
-
 /* {{{ proto string nl2br(string str) U
    Converts newlines to HTML line breaks */
 PHP_FUNCTION(nl2br)
@@ -5487,7 +5483,6 @@
 }
 /* }}} */
 
-
 /* {{{ proto string strip_tags(string str [, string allowable_tags]) U
    Strips HTML and PHP tags from a string */
 PHP_FUNCTION(strip_tags)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to