X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=src%2Fphp_http_params.c;h=c9feccb6c56705e63088ded27a3a0f716acb7969;hp=b51ab712657cab9e0fff62a8ca3d7ee982f2151c;hb=43a9a6f8cb56e25c3770d652ce77045f89f68ca6;hpb=a5e66b221dbf5a52cc770f4d7f46f05fe88784ba diff --git a/src/php_http_params.c b/src/php_http_params.c index b51ab71..c9feccb 100644 --- a/src/php_http_params.c +++ b/src/php_http_params.c @@ -253,11 +253,13 @@ static inline void sanitize_key(unsigned flags, const char *str, size_t len, zva 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) { @@ -554,6 +556,8 @@ static void push_param(HashTable *params, php_http_params_state_t *state, const if (state->val.str) { if (0 < (state->val.len = state->input.str - state->val.str)) { sanitize_value(opts->flags, state->val.str, state->val.len, state->current.val, state->rfc5987); + } else { + ZVAL_EMPTY_STRING(state->current.val); } state->rfc5987 = 0; } else if (state->arg.str) { @@ -1027,6 +1031,12 @@ void php_http_params_separator_free(php_http_params_token_t **separator) } } +static zend_class_entry *php_http_params_class_entry; +zend_class_entry *php_http_params_get_class_entry(void) +{ + return php_http_params_class_entry; +} + ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams___construct, 0, 0, 0) ZEND_ARG_INFO(0, params) ZEND_ARG_INFO(0, param_sep) @@ -1043,7 +1053,7 @@ PHP_METHOD(HttpParams, __construct) php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|z!/z/z/z/l", &zparams, ¶m_sep, &arg_sep, &val_sep, &flags), invalid_arg, return); - zend_replace_error_handling(EH_THROW, php_http_exception_runtime_class_entry, &zeh); + zend_replace_error_handling(EH_THROW, php_http_get_exception_runtime_class_entry(), &zeh); { switch (ZEND_NUM_ARGS()) { case 5: @@ -1283,8 +1293,6 @@ static zend_function_entry php_http_params_methods[] = { EMPTY_FUNCTION_ENTRY }; -zend_class_entry *php_http_params_class_entry; - PHP_MINIT_FUNCTION(http_params) { zend_class_entry ce = {0};