iliaa           Sat Dec  9 14:17:17 2006 UTC

  Modified files:              
    /php-src/ext/filter filter.c 
    /php-src    run-tests.php 
    /php-src/ext/filter/tests   041.phpt 
    /php-src/main       php_variables.c 
  Log:
  MFB:
        Fixed handling of multiple cookies with the same name.
        Added support for cookies into run-tests.php
        
  
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/filter.c?r1=1.82&r2=1.83&diff_format=u
Index: php-src/ext/filter/filter.c
diff -u php-src/ext/filter/filter.c:1.82 php-src/ext/filter/filter.c:1.83
--- php-src/ext/filter/filter.c:1.82    Fri Dec  8 17:03:26 2006
+++ php-src/ext/filter/filter.c Sat Dec  9 14:17:17 2006
@@ -19,7 +19,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: filter.c,v 1.82 2006/12/08 17:03:26 tony2001 Exp $ */
+/* $Id: filter.c,v 1.83 2006/12/09 14:17:17 iliaa Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -275,7 +275,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_row( 2, "Input Validation and Filtering", 
"enabled" );
-       php_info_print_table_row( 2, "Revision", "$Revision: 1.82 $");
+       php_info_print_table_row( 2, "Revision", "$Revision: 1.83 $");
        php_info_print_table_end();
 
        DISPLAY_INI_ENTRIES();
@@ -370,6 +370,16 @@
                        break;
        }
 
+       /* 
+        * According to rfc2965, more specific paths are listed above the less 
specific ones.
+        * If we encounter a duplicate cookie name, we should skip it, since it 
is not possible
+        * to have the same (plain text) cookie name for the same path and we 
should not overwrite
+        * more specific cookies with the less specific ones.
+       */
+       if (arg == PARSE_COOKIE && orig_array_ptr && 
zend_symtable_exists(Z_ARRVAL_P(orig_array_ptr), var, strlen(var)+1)) {
+               return 0;
+       }
+
        if (array_ptr) {
                /* Make a copy of the variable name, as 
php_register_variable_ex seems to
                 * modify it */
http://cvs.php.net/viewvc.cgi/php-src/run-tests.php?r1=1.310&r2=1.311&diff_format=u
Index: php-src/run-tests.php
diff -u php-src/run-tests.php:1.310 php-src/run-tests.php:1.311
--- php-src/run-tests.php:1.310 Mon Dec  4 13:07:00 2006
+++ php-src/run-tests.php       Sat Dec  9 14:17:17 2006
@@ -23,7 +23,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: run-tests.php,v 1.310 2006/12/04 13:07:00 tony2001 Exp $ */
+/* $Id: run-tests.php,v 1.311 2006/12/09 14:17:17 iliaa Exp $ */
 
 /* Sanity check to ensure that pcre extension needed by this script is 
available.
  * In the event it is not, print a nice error message indicating that this 
script will
@@ -400,7 +400,7 @@
                                        $html_output = is_resource($html_file);
                                        break;
                                case '--version':
-                                       echo '$Revision: 1.310 $'."\n";
+                                       echo '$Revision: 1.311 $'."\n";
                                        exit(1);
                                default:
                                        echo "Illegal switch specified!\n";
@@ -968,13 +968,14 @@
                'TEST'   => '',
                'SKIPIF' => '',
                'GET'    => '',
+               'COOKIE' => '',
                'POST_RAW' => '',
                'POST'   => '',
                'UPLOAD' => '',
                'ARGS'   => '',
        );
 
-       $fp = @fopen($file, "rt") or error("Cannot open test file: $file");
+       $fp = fopen($file, "rt") or error("Cannot open test file: $file");
 
        $borked = false;
        $bork_info = '';
@@ -1062,7 +1063,7 @@
        $tested = trim($section_text['TEST']);
 
        /* For GET/POST tests, check if cgi sapi is available and if it is, use 
it. */
-       if ((!empty($section_text['GET']) || !empty($section_text['POST']))) {
+       if (!empty($section_text['GET']) || !empty($section_text['POST']) || 
!empty($section_text['POST_RAW']) || !empty($section_text['COOKIE'])) {
                if (!strncasecmp(PHP_OS, "win", 3) && file_exists(dirname($php) 
."/php-cgi.exe")) {
                        $old_php = $php;
                        $php = realpath(dirname($php) ."/php-cgi.exe") .' -C ';
@@ -1341,6 +1342,12 @@
        $env['PATH_TRANSLATED'] = $test_file;
        $env['SCRIPT_FILENAME'] = $test_file;
 
+       if (array_key_exists('COOKIE', $section_text)) {
+               $env['HTTP_COOKIE'] = trim($section_text['COOKIE']);
+       } else {
+               $env['HTTP_COOKIE'] = '';
+       }
+
        $args = $section_text['ARGS'] ? ' -- '.$section_text['ARGS'] : '';
 
        if (array_key_exists('POST_RAW', $section_text) && 
!empty($section_text['POST_RAW'])) {
@@ -1400,6 +1407,7 @@
 REDIRECT_STATUS = " . $env['REDIRECT_STATUS'] . "
 REQUEST_METHOD  = " . $env['REQUEST_METHOD'] . "
 SCRIPT_FILENAME = " . $env['SCRIPT_FILENAME'] . "
+HTTP_COOKIE     = " . $env['HTTP_COOKIE'] . "
 COMMAND $cmd
 ";
 
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/tests/041.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/filter/tests/041.phpt
diff -u /dev/null php-src/ext/filter/tests/041.phpt:1.2
--- /dev/null   Sat Dec  9 14:17:17 2006
+++ php-src/ext/filter/tests/041.phpt   Sat Dec  9 14:17:17 2006
@@ -0,0 +1,32 @@
+--TEST--
+COOKIE multiple cookie test
+--INI--
+filter.default=stripped
+filter.default_flags=0
+--COOKIE--
+abc=dir; def=true; abc=root; xyz="foo bar";
+--FILE--
+<?php 
+var_dump($_COOKIE);
+var_dump(filter_has_var(INPUT_COOKIE, "abc"));
+var_dump(filter_input(INPUT_COOKIE, "abc"));
+var_dump(filter_input(INPUT_COOKIE, "def"));
+var_dump(filter_input(INPUT_COOKIE, "xyz"));
+var_dump(filter_has_var(INPUT_COOKIE, "bogus"));
+var_dump(filter_input(INPUT_COOKIE, "xyz", FILTER_SANITIZE_SPECIAL_CHARS));
+?>
+--EXPECT--
+array(3) {
+  ["abc"]=>
+  string(3) "dir"
+  ["def"]=>
+  string(4) "true"
+  ["xyz"]=>
+  string(17) "&#34;foo bar&#34;"
+}
+bool(true)
+string(3) "dir"
+string(4) "true"
+string(9) ""foo bar""
+bool(false)
+string(17) "&#34;foo bar&#34;"
http://cvs.php.net/viewvc.cgi/php-src/main/php_variables.c?r1=1.133&r2=1.134&diff_format=u
Index: php-src/main/php_variables.c
diff -u php-src/main/php_variables.c:1.133 php-src/main/php_variables.c:1.134
--- php-src/main/php_variables.c:1.133  Sat Dec  9 13:14:06 2006
+++ php-src/main/php_variables.c        Sat Dec  9 14:17:17 2006
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_variables.c,v 1.133 2006/12/09 13:14:06 iliaa Exp $ */
+/* $Id: php_variables.c,v 1.134 2006/12/09 14:17:17 iliaa Exp $ */
 
 #include <stdio.h>
 #include "php.h"
@@ -511,7 +511,7 @@
                                var++;
                        }
                        if (var == val || *var == '\0') {
-                               goto next_cookie;
+                               goto next_var;
                        }
                }
 

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

Reply via email to