fix regression introduced with http\Params::PARSE_RFC5987
authorMichael Wallner <mike@php.net>
Mon, 6 Jun 2016 07:18:46 +0000 (09:18 +0200)
committerMichael Wallner <mike@php.net>
Mon, 6 Jun 2016 07:18:46 +0000 (09:18 +0200)
negotiation using the params parser would receive param keys without the
trailing asterisk, stripped by http\Params::PARSE_RFC5987

src/php_http_negotiate.c
src/php_http_params.c
tests/params017.phpt

index a74875b..3907501 100644 (file)
@@ -115,6 +115,7 @@ HashTable *php_http_negotiate(const char *value_str, size_t value_len, HashTable
                php_http_params_opts_default_get(&opts);
                opts.input.str = estrndup(value_str, value_len);
                opts.input.len = value_len;
+               opts.flags &= ~PHP_HTTP_PARAMS_RFC5987;
                php_http_params_parse(&params, &opts TSRMLS_CC);
                efree(opts.input.str);
 
index 5adeb91..98ac06f 100644 (file)
@@ -234,11 +234,13 @@ static inline void sanitize_key(unsigned flags, char *str, size_t len, zval *zv,
                return;
        }
 
-       eos = &Z_STRVAL_P(zv)[Z_STRLEN_P(zv)-1];
-       if (*eos == '*') {
-               *eos = '\0';
-               *rfc5987 = 1;
-               Z_STRLEN_P(zv) -= 1;
+       if (flags & PHP_HTTP_PARAMS_RFC5987) {
+               eos = &Z_STRVAL_P(zv)[Z_STRLEN_P(zv)-1];
+               if (*eos == '*') {
+                       *eos = '\0';
+                       *rfc5987 = 1;
+                       Z_STRLEN_P(zv) -= 1;
+               }
        }
 
        if (flags & PHP_HTTP_PARAMS_URLENCODED) {
index b3587e5..95e8c54 100644 (file)
@@ -19,7 +19,7 @@ $p = current(http\Header::parse($link, "http\\Header"))->getParams(
        http\Params::DEF_PARAM_SEP,
        http\Params::DEF_ARG_SEP,
        http\Params::DEF_VAL_SEP,
-       http\Params::PARSE_RFC5988 | http\Params::PARSE_ESCAPED
+       http\Params::PARSE_RFC5987 | http\Params::PARSE_RFC5988 | http\Params::PARSE_ESCAPED
 );
 var_dump($p->params);
 var_dump((string)$p);