From: Michael Wallner Date: Mon, 6 Jun 2016 07:18:46 +0000 (+0200) Subject: fix regression introduced with http\Params::PARSE_RFC5987 X-Git-Tag: RELEASE_2_6_0_BETA1~19 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=75323793e113441c79c18cd9a57533dd592d3ff7;p=m6w6%2Fext-http fix regression introduced with http\Params::PARSE_RFC5987 negotiation using the params parser would receive param keys without the trailing asterisk, stripped by http\Params::PARSE_RFC5987 --- diff --git a/src/php_http_negotiate.c b/src/php_http_negotiate.c index a74875b..3907501 100644 --- a/src/php_http_negotiate.c +++ b/src/php_http_negotiate.c @@ -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(¶ms, &opts TSRMLS_CC); efree(opts.input.str); diff --git a/src/php_http_params.c b/src/php_http_params.c index 5adeb91..98ac06f 100644 --- a/src/php_http_params.c +++ b/src/php_http_params.c @@ -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) { diff --git a/tests/params017.phpt b/tests/params017.phpt index b3587e5..95e8c54 100644 --- a/tests/params017.phpt +++ b/tests/params017.phpt @@ -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);