]> granicus.if.org Git - php/commitdiff
Strip leading spaces from cookie names, that can come from multi-cookie
authorIlia Alshanetsky <iliaa@php.net>
Sat, 9 Dec 2006 13:01:23 +0000 (13:01 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sat, 9 Dec 2006 13:01:23 +0000 (13:01 +0000)
headers where ; can be followed by any number of spaces.

main/php_variables.c

index 789511391f2d8cc0d90df07fea83d1498e648840..c77b939fd3f0a0be207a871130641d0d816e8f40 100644 (file)
@@ -342,6 +342,17 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
        
        while (var) {
                val = strchr(var, '=');
+
+               if (arg == PARSE_COOKIE) {
+                       /* Remove leading spaces from cookie names, needed for multi-cookie header where ; can be followed by a space */
+                       while (isspace(*var)) {
+                               var++;
+                       }
+                       if (var == val || *var == '\0') {
+                               goto next_cookie;
+                       }
+               }
+
                if (val) { /* have a value */
                        int val_len;
                        unsigned int new_val_len;
@@ -366,6 +377,7 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
                        }
                        efree(val);
                }
+next_cookie:
                var = php_strtok_r(NULL, separator, &strtok_buf);
        }