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 a74875b7378647664a1fe35a63b72c8f17995d79..3907501e420a13878e3a6777f0dbba88bf6ff381 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 5adeb91c761f390bd3e6705ea71eb6eaf5225422..98ac06f7c658633eb437d6d3bca3fc7d7532d2b7 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 b3587e53e40a464bbb894aadd84d47a219afd2f5..95e8c54308916839507d8f78437227b587f95f23 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);