Skip to content

Commit 7d33a30

Browse files
committed
Handle floats directly in http_build_query()
1 parent ec7c7a7 commit 7d33a30

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

ext/standard/http.c

+15-14
Original file line numberDiff line numberDiff line change
@@ -193,26 +193,27 @@ PHPAPI void php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
193193
case IS_LONG:
194194
smart_str_append_long(formstr, Z_LVAL_P(zdata));
195195
break;
196+
case IS_DOUBLE: {
197+
zend_string *ekey;
198+
zend_string *tmp = zend_double_to_str(Z_DVAL_P(zdata));
199+
if (enc_type == PHP_QUERY_RFC3986) {
200+
ekey = php_raw_url_encode(ZSTR_VAL(tmp), ZSTR_LEN(tmp));
201+
} else {
202+
ekey = php_url_encode(ZSTR_VAL(tmp), ZSTR_LEN(tmp));
203+
}
204+
smart_str_append(formstr, ekey);
205+
zend_string_free(tmp);
206+
zend_string_free(ekey);
207+
break;
208+
}
196209
case IS_FALSE:
197210
smart_str_appendl(formstr, "0", sizeof("0")-1);
198211
break;
199212
case IS_TRUE:
200213
smart_str_appendl(formstr, "1", sizeof("1")-1);
201214
break;
202-
default:
203-
{
204-
zend_string *ekey;
205-
zend_string *tmp;
206-
zend_string *str= zval_get_tmp_string(zdata, &tmp);
207-
if (enc_type == PHP_QUERY_RFC3986) {
208-
ekey = php_raw_url_encode(ZSTR_VAL(str), ZSTR_LEN(str));
209-
} else {
210-
ekey = php_url_encode(ZSTR_VAL(str), ZSTR_LEN(str));
211-
}
212-
smart_str_append(formstr, ekey);
213-
zend_tmp_string_release(tmp);
214-
zend_string_free(ekey);
215-
}
215+
/* All possible types are either handled here or previously */
216+
EMPTY_SWITCH_DEFAULT_CASE();
216217
}
217218
}
218219
} ZEND_HASH_FOREACH_END();

0 commit comments

Comments
 (0)