derick          Sat Nov 29 10:24:35 2003 EDT

  Modified files:              
    /php-src    README.input_filter 
    /php-src/ext/mbstring       mb_gpc.c 
    /php-src/main       SAPI.c SAPI.h php_variables.c rfc1867.c 
  Log:
  - Fix sapi_input_filter patch. Returning 1 from the filter handler should
    make PHP register the variable, returning 0 shouldn't. The new length of
    the variables being filtered is now returned in the new_val_len argument
    of the function.
  
  
Index: php-src/README.input_filter
diff -u php-src/README.input_filter:1.2 php-src/README.input_filter:1.3
--- php-src/README.input_filter:1.2     Thu Feb 20 17:21:46 2003
+++ php-src/README.input_filter Sat Nov 29 10:24:33 2003
@@ -85,11 +85,11 @@
 {
     php_info_print_table_start();
     php_info_print_table_row( 2, "My Input Filter Support", "enabled" );
-    php_info_print_table_row( 2, "Revision", "$Revision: 1.2 $");
+    php_info_print_table_row( 2, "Revision", "$Revision: 1.3 $");
     php_info_print_table_end();
 }
 
-unsigned int  my_sapi_input_filter(int arg, char *var, char **val, unsigned int 
val_len)
+unsigned int  my_sapi_input_filter(int arg, char *var, char **val, unsigned int 
val_len, unsigned int *new_val_len)
 {
     zval new_var;
     zval *array_ptr = NULL;
@@ -137,7 +137,8 @@
 
     php_strip_tags(*val, val_len, NULL, NULL, 0);
 
-    return strlen(*val);
+    *new_val_len = strlen(*val);
+       return 1;
 }
 
 PHP_FUNCTION(my_get_raw)
Index: php-src/ext/mbstring/mb_gpc.c
diff -u php-src/ext/mbstring/mb_gpc.c:1.8 php-src/ext/mbstring/mb_gpc.c:1.9
--- php-src/ext/mbstring/mb_gpc.c:1.8   Sat Aug 23 04:59:47 2003
+++ php-src/ext/mbstring/mb_gpc.c       Sat Nov 29 10:24:34 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mb_gpc.c,v 1.8 2003/08/23 08:59:47 hirokawa Exp $ */
+/* $Id: mb_gpc.c,v 1.9 2003/11/29 15:24:34 derick Exp $ */
 
 /* {{{ includes */
 #ifdef HAVE_CONFIG_H
@@ -204,7 +204,8 @@
        char *var, *val, *s1, *s2;
        char *strtok_buf = NULL, **val_list = NULL;
        zval *array_ptr = (zval *) arg;
-       int n, num, val_len, *len_list = NULL, *elist, elistsz;
+       int n, num, *len_list = NULL, *elist, elistsz;
+       unsigned int val_len, new_val_len;
        enum mbfl_no_encoding from_encoding, to_encoding;
        mbfl_string string, resvar, resval;
        mbfl_encoding_detector *identd = NULL; 
@@ -342,9 +343,10 @@
                        val_len = len_list[n];
                }
                n++;
-               val_len = sapi_module.input_filter(data_type, var, &val, val_len 
TSRMLS_CC);
-               /* add variable to symbol table */
-               php_register_variable_safe(var, val, val_len, array_ptr TSRMLS_CC);
+               if (sapi_module.input_filter(data_type, var, &val, val_len, 
&new_val_len TSRMLS_CC)) {
+                       /* add variable to symbol table */
+                       php_register_variable_safe(var, val, new_val_len, array_ptr 
TSRMLS_CC);
+               }
                if (convd != NULL){
                        mbfl_string_clear(&resvar);
                        mbfl_string_clear(&resval);
Index: php-src/main/SAPI.c
diff -u php-src/main/SAPI.c:1.180 php-src/main/SAPI.c:1.181
--- php-src/main/SAPI.c:1.180   Sat Nov 22 16:10:47 2003
+++ php-src/main/SAPI.c Sat Nov 29 10:24:34 2003
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: SAPI.c,v 1.180 2003/11/22 21:10:47 sesser Exp $ */
+/* $Id: SAPI.c,v 1.181 2003/11/29 15:24:34 derick Exp $ */
 
 #include <ctype.h>
 #include <sys/stat.h>
@@ -831,7 +831,7 @@
        return SUCCESS;
 }
 
-SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char 
*var, char **val, unsigned int val_len TSRMLS_DC))
+SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char 
*var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC))
 {
        sapi_module.input_filter = input_filter;
        return SUCCESS;
Index: php-src/main/SAPI.h
diff -u php-src/main/SAPI.h:1.105 php-src/main/SAPI.h:1.106
--- php-src/main/SAPI.h:1.105   Tue Sep  2 09:34:23 2003
+++ php-src/main/SAPI.h Sat Nov 29 10:24:35 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: SAPI.h,v 1.105 2003/09/02 13:34:23 abies Exp $ */
+/* $Id: SAPI.h,v 1.106 2003/11/29 15:24:35 derick Exp $ */
 
 #ifndef SAPI_H
 #define SAPI_H
@@ -181,7 +181,7 @@
 SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry);
 SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D));
 SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval 
*destArray TSRMLS_DC));
-SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char 
*var, char **val, unsigned int val_len TSRMLS_DC));
+SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char 
*var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC));
 
 SAPI_API int sapi_flush(TSRMLS_D);
 SAPI_API struct stat *sapi_get_stat(TSRMLS_D);
@@ -244,7 +244,7 @@
        int (*get_target_uid)(uid_t * TSRMLS_DC);
        int (*get_target_gid)(gid_t * TSRMLS_DC);
 
-       unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int 
val_len TSRMLS_DC);
+       unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int 
val_len, unsigned int *new_val_len TSRMLS_DC);
        
        void (*ini_defaults)(HashTable *configuration_hash);
        int phpinfo_as_text;
Index: php-src/main/php_variables.c
diff -u php-src/main/php_variables.c:1.72 php-src/main/php_variables.c:1.73
--- php-src/main/php_variables.c:1.72   Wed Nov 26 04:53:22 2003
+++ php-src/main/php_variables.c        Sat Nov 29 10:24:35 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_variables.c,v 1.72 2003/11/26 09:53:22 derick Exp $ */
+/* $Id: php_variables.c,v 1.73 2003/11/29 15:24:35 derick Exp $ */
 
 #include <stdio.h>
 #include "php.h"
@@ -207,14 +207,13 @@
        while (var) {
                val = strchr(var, '=');
                if (val) { /* have a value */
-                       int val_len;
+                       unsigned int val_len, new_val_len;
 
                        *val++ = '\0';
                        php_url_decode(var, strlen(var));
                        val_len = php_url_decode(val, strlen(val));
-                       val_len = sapi_module.input_filter(PARSE_POST, var, &val, 
val_len TSRMLS_CC);
-                       if (val_len) {
-                               php_register_variable_safe(var, val, val_len, 
array_ptr TSRMLS_CC);
+                       if (sapi_module.input_filter(PARSE_POST, var, &val, val_len, 
&new_val_len TSRMLS_CC)) {
+                               php_register_variable_safe(var, val, new_val_len, 
array_ptr TSRMLS_CC);
                        }
                }
                var = php_strtok_r(NULL, "&", &strtok_buf);
@@ -305,13 +304,13 @@
                val = strchr(var, '=');
                if (val) { /* have a value */
                        int val_len;
+                       unsigned int new_val_len;
 
                        *val++ = '\0';
                        php_url_decode(var, strlen(var));
                        val_len = php_url_decode(val, strlen(val));
-                       val_len = sapi_module.input_filter(arg, var, &val, val_len 
TSRMLS_CC);
-                       if (val_len) {
-                               php_register_variable_safe(var, val, val_len, 
array_ptr TSRMLS_CC);
+                       if (sapi_module.input_filter(PARSE_POST, var, &val, val_len, 
&new_val_len TSRMLS_CC)) {
+                               php_register_variable_safe(var, val, new_val_len, 
array_ptr TSRMLS_CC);
                        }
                } else {
                        php_url_decode(var, strlen(var));
Index: php-src/main/rfc1867.c
diff -u php-src/main/rfc1867.c:1.147 php-src/main/rfc1867.c:1.148
--- php-src/main/rfc1867.c:1.147        Wed Nov 26 04:53:22 2003
+++ php-src/main/rfc1867.c      Sat Nov 29 10:24:35 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: rfc1867.c,v 1.147 2003/11/26 09:53:22 derick Exp $ */
+/* $Id: rfc1867.c,v 1.148 2003/11/29 15:24:35 derick Exp $ */
 
 /*
  *  This product includes software developed by the Apache Group
@@ -881,14 +881,13 @@
                        if (!filename && param) {
 
                                char *value = multipart_buffer_read_body(mbuff 
TSRMLS_CC);
-                               int   val_len;
+                               unsigned int new_val_len;
 
                                if (!value) {
                                        value = estrdup("");
                                }
 
-                               val_len = sapi_module.input_filter(PARSE_POST, param, 
&value, strlen(value) TSRMLS_CC);
-                               if (val_len) {
+                               if (sapi_module.input_filter(PARSE_POST, param, 
&value, strlen(value), &new_val_len TSRMLS_CC)) {
 #if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
                                        if (php_mb_encoding_translation(TSRMLS_C)) {
                                                php_mb_gpc_stack_variable(param, 
value, &val_list, &len_list, 

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

Reply via email to