fix #47
[m6w6/ext-http] / src / php_http_params.c
index 5adeb91..c0071ac 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) {
@@ -520,9 +522,15 @@ static void merge_param(HashTable *params, zval *zdata, zval ***current_param, z
 
 static void push_param(HashTable *params, php_http_params_state_t *state, const php_http_params_opts_t *opts TSRMLS_DC)
 {
+       if (!state->current.val) {
+               return;
+       }
+
        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 TSRMLS_CC);
+               } else {
+                       ZVAL_EMPTY_STRING(*(state->current.val));
                }
                state->rfc5987 = 0;
        } else if (state->arg.str) {