diff options
| author | Ilia Alshanetsky <iliaa@php.net> | 2006-12-09 14:14:29 +0000 |
|---|---|---|
| committer | Ilia Alshanetsky <iliaa@php.net> | 2006-12-09 14:14:29 +0000 |
| commit | 94e3f478d75f18fb8bec2527bc7a56fe8dce3b6d (patch) | |
| tree | a5b523035da5840f830e862a8112ae9787a4afca /ext/filter | |
| parent | 847741cb08f79676c80e7fffadc108854683f343 (diff) | |
| download | php-git-94e3f478d75f18fb8bec2527bc7a56fe8dce3b6d.tar.gz | |
Fixed handling of multiple cookies with the same name.
Added support for cookies into run-tests.php
Diffstat (limited to 'ext/filter')
| -rw-r--r-- | ext/filter/filter.c | 10 | ||||
| -rw-r--r-- | ext/filter/tests/041.phpt | 32 |
2 files changed, 42 insertions, 0 deletions
diff --git a/ext/filter/filter.c b/ext/filter/filter.c index b2107aaa00..6f692787b9 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -370,6 +370,16 @@ static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned int 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 */ diff --git a/ext/filter/tests/041.phpt b/ext/filter/tests/041.phpt new file mode 100644 index 0000000000..e313cb30df --- /dev/null +++ b/ext/filter/tests/041.phpt @@ -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) ""foo bar"" +} +bool(true) +string(3) "dir" +string(4) "true" +string(9) ""foo bar"" +bool(false) +string(17) ""foo bar"" |
