From: Michael Wallner Date: Thu, 7 May 2015 20:10:31 +0000 (+0200) Subject: rfc5988 fixes X-Git-Tag: RELEASE_2_5_0_RC1~4 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=16bf75db1f89db511833657630cff588576088e2 rfc5988 fixes --- diff --git a/php_http_params.c b/php_http_params.c index 34bc928..b91314d 100644 --- a/php_http_params.c +++ b/php_http_params.c @@ -291,6 +291,12 @@ static inline void sanitize_rfc5987(zval *zv, char **language, zend_bool *latin1 } } +static inline void sanitize_rfc5988(char *str, size_t len, zval *zv TSRMLS_DC) +{ + zval_dtor(zv); + php_trim(str, len, " ><", 3, zv, 3 TSRMLS_CC); +} + static void utf8encode(zval *zv) { size_t pos, len = 0; @@ -542,11 +548,11 @@ static void push_param(HashTable *params, php_http_params_state_t *state, const MAKE_STD_ZVAL(key); ZVAL_NULL(key); if (opts->flags & PHP_HTTP_PARAMS_RFC5988) { - state->param.str += 1; /* < */ - state->param.len -= 2; /* > */ + sanitize_rfc5988(state->param.str, state->param.len, key TSRMLS_CC); + } else { + sanitize_key(opts->flags, state->param.str, state->param.len, key, &rfc5987 TSRMLS_CC); + state->rfc5987 = rfc5987; } - sanitize_key(opts->flags, state->param.str, state->param.len, key, &rfc5987 TSRMLS_CC); - state->rfc5987 = rfc5987; if (Z_TYPE_P(key) != IS_STRING) { merge_param(params, key, &state->current.val, &state->current.args TSRMLS_CC); } else if (Z_STRLEN_P(key)) { @@ -628,7 +634,7 @@ HashTable *php_http_params_parse(HashTable *params, const php_http_params_opts_t while (state.input.len) { if ((opts->flags & PHP_HTTP_PARAMS_RFC5988) && !state.arg.str) { - if (!state.param.str && *state.input.str == '<') { + if (*state.input.str == '<') { state.quotes = 1; } else if (*state.input.str == '>') { state.quotes = 0;