release 2.4.0
[m6w6/ext-http] / php_http_params.c
index 1757ec9fc5f68dc0d62cf6712b4bbd5cc62c742c..ce785ecbe03efef1daad18b9acb0948fc5f9a61a 100644 (file)
@@ -224,6 +224,10 @@ static inline void sanitize_key(unsigned flags, char *str, size_t len, zval *zv,
        if (flags & PHP_HTTP_PARAMS_ESCAPED) {
                sanitize_escaped(zv TSRMLS_CC);
        }
+       
+       if (!Z_STRLEN_P(zv)) {
+               return;
+       }
 
        eos = &Z_STRVAL_P(zv)[Z_STRLEN_P(zv)-1];
        if (*eos == '*') {
@@ -253,7 +257,7 @@ static inline void sanitize_rfc5987(zval *zv, char **language, zend_bool *latin1
        switch (Z_STRVAL_P(zv)[0]) {
        case 'I':
        case 'i':
-               if (!strncasecmp(Z_STRVAL_P(zv), ZEND_STRL("iso-8859-1"))) {
+               if (!strncasecmp(Z_STRVAL_P(zv), "iso-8859-1", lenof("iso-8859-1"))) {
                        *latin1 = 1;
                        ptr = Z_STRVAL_P(zv) + lenof("iso-8859-1");
                        break;
@@ -261,7 +265,7 @@ static inline void sanitize_rfc5987(zval *zv, char **language, zend_bool *latin1
                /* no break */
        case 'U':
        case 'u':
-               if (!strncasecmp(Z_STRVAL_P(zv), ZEND_STRL("utf-8"))) {
+               if (!strncasecmp(Z_STRVAL_P(zv), "utf-8", lenof("utf-8"))) {
                        *latin1 = 0;
                        ptr = Z_STRVAL_P(zv) + lenof("utf-8");
                        break;
@@ -343,7 +347,7 @@ static inline void sanitize_value(unsigned flags, char *str, size_t len, zval *z
                ZVAL_COPY_VALUE(tmp, zv);
                array_init(zv);
                add_assoc_zval(zv, language, tmp);
-               STR_FREE(language);
+               PTR_FREE(language);
        }
 }
 
@@ -570,7 +574,7 @@ static void push_param(HashTable *params, php_http_params_state_t *state, const
 }
 
 static inline zend_bool check_str(const char *chk_str, size_t chk_len, const char *sep_str, size_t sep_len) {
-       return 0 < sep_len && chk_len >= sep_len && !memcmp(chk_str, sep_str, sep_len);
+       return 0 < sep_len && chk_len >= sep_len && *chk_str == *sep_str && !memcmp(chk_str + 1, sep_str + 1, sep_len - 1);
 }
 
 static size_t check_sep(php_http_params_state_t *state, php_http_params_token_t **separators)
@@ -881,7 +885,7 @@ void php_http_params_separator_free(php_http_params_token_t **separator)
        php_http_params_token_t **sep = separator;
        if (sep) {
                while (*sep) {
-                       STR_FREE((*sep)->str);
+                       PTR_FREE((*sep)->str);
                        efree(*sep);
                        ++sep;
                }