X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=src%2Fphp_http_params.c;h=92cc558962af525355cfa0fc32672dd858e8e3a5;hp=c9feccb6c56705e63088ded27a3a0f716acb7969;hb=b3831bc5f19cf32880ea19341c3527f0e9553517;hpb=7214e1aef4efce10bcc509d2a741acef88d28781 diff --git a/src/php_http_params.c b/src/php_http_params.c index c9feccb..92cc558 100644 --- a/src/php_http_params.c +++ b/src/php_http_params.c @@ -248,7 +248,7 @@ static inline void sanitize_key(unsigned flags, const char *str, size_t len, zva if (flags & PHP_HTTP_PARAMS_ESCAPED) { sanitize_escaped(zv); } - + if (!Z_STRLEN_P(zv)) { return; } @@ -489,7 +489,7 @@ static void merge_param(HashTable *params, zval *zdata, zval **current_param, zv zval *test_ptr; while (Z_TYPE_P(zdata_ptr) == IS_ARRAY && (test_ptr = zend_hash_get_current_data(Z_ARRVAL_P(zdata_ptr)))) { - if (Z_TYPE_P(test_ptr) == IS_ARRAY) { + if (Z_TYPE_P(test_ptr) == IS_ARRAY && Z_TYPE_P(ptr) == IS_ARRAY) { zval *tmp_ptr = ptr; /* now find key in ptr */ @@ -554,7 +554,9 @@ static void merge_param(HashTable *params, zval *zdata, zval **current_param, zv static void push_param(HashTable *params, php_http_params_state_t *state, const php_http_params_opts_t *opts) { if (state->val.str) { - if (0 < (state->val.len = state->input.str - state->val.str)) { + if (!state->current.val) { + return; + } else 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); @@ -639,7 +641,7 @@ static size_t check_sep(php_http_params_state_t *state, php_http_params_token_t if (state->quotes || state->escape) { return 0; } - + if (sep) while (*sep) { if (check_str(state->input.str, state->input.len, (*sep)->str, (*sep)->len)) { return (*sep)->len; @@ -689,7 +691,7 @@ HashTable *php_http_params_parse(HashTable *params, const php_http_params_opts_t } else { state.escape = (*state.input.str == '\\'); } - + if (!state.param.str) { /* initialize */ skip_sep(0, &state, opts->param, opts->arg, opts->val); @@ -743,7 +745,7 @@ HashTable *php_http_params_parse(HashTable *params, const php_http_params_opts_t } } } - + if (state.input.len) { ++state.input.str; --state.input.len;