From d1121da9cad0383aa661a8d0720dd598e448400c Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 21 Dec 2005 19:49:39 +0000 Subject: [PATCH] - only encode if there's anything to encode --- http_url_api.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/http_url_api.c b/http_url_api.c index c8e9e78..575c4f5 100644 --- a/http_url_api.c +++ b/http_url_api.c @@ -299,8 +299,6 @@ PHP_HTTP_API STATUS _http_urlencode_hash_recursive(HashTable *ht, phpstr *str, c return FAILURE; } } else { - char *encoded_val; - int encoded_len; zval *cpy, *val = convert_to_type_ex(IS_STRING, *data, &cpy); if (PHPSTR_LEN(str)) { @@ -309,9 +307,14 @@ PHP_HTTP_API STATUS _http_urlencode_hash_recursive(HashTable *ht, phpstr *str, c phpstr_append(str, PHPSTR_VAL(&new_prefix), PHPSTR_LEN(&new_prefix)); phpstr_appends(str, "="); - encoded_val = php_url_encode(Z_STRVAL_P(val), Z_STRLEN_P(val), &encoded_len); - phpstr_append(str, encoded_val, encoded_len); - efree(encoded_val); + if (Z_STRLEN_P(val)) { + char *encoded_val; + int encoded_len; + + encoded_val = php_url_encode(Z_STRVAL_P(val), Z_STRLEN_P(val), &encoded_len); + phpstr_append(str, encoded_val, encoded_len); + efree(encoded_val); + } if (cpy) { zval_ptr_dtor(&cpy); -- 2.30.2