- only encode if there's anything to encode
authorMichael Wallner <mike@php.net>
Wed, 21 Dec 2005 19:49:39 +0000 (19:49 +0000)
committerMichael Wallner <mike@php.net>
Wed, 21 Dec 2005 19:49:39 +0000 (19:49 +0000)
http_url_api.c

index c8e9e78ea8597f7b0d2170a747efc0201387bb86..575c4f57a856b63f42a06623f9ec7944b609101e 100644 (file)
@@ -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);