@@ -27,10 +27,10 @@ static void php_url_encode_scalar(zval *scalar, smart_str *form_str,
2727 const char * index_string , size_t index_string_len ,
2828 const char * num_prefix , size_t num_prefix_len ,
2929 const zend_string * key_prefix ,
30- const char * arg_sep , size_t arg_sep_len )
30+ const zend_string * arg_sep )
3131{
3232 if (form_str -> s ) {
33- smart_str_appendl (form_str , arg_sep , arg_sep_len );
33+ smart_str_append (form_str , arg_sep );
3434 }
3535 /* Simple key=value */
3636 if (key_prefix ) {
@@ -87,7 +87,7 @@ static void php_url_encode_scalar(zval *scalar, smart_str *form_str,
8787PHPAPI void php_url_encode_hash_ex (HashTable * ht , smart_str * formstr ,
8888 const char * num_prefix , size_t num_prefix_len ,
8989 const zend_string * key_prefix ,
90- zval * type , const char * arg_sep , size_t arg_sep_len , int enc_type )
90+ zval * type , const zend_string * arg_sep , int enc_type )
9191{
9292 zend_string * key = NULL ;
9393 const char * prop_name ;
@@ -103,11 +103,8 @@ PHPAPI void php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
103103
104104 if (!arg_sep ) {
105105 arg_sep = PG (arg_separator .output );
106- if (!* arg_sep ) {
107- arg_sep = "&" ;
108- arg_sep_len = 1 ;
109- } else {
110- arg_sep_len = strlen (arg_sep );
106+ if (ZSTR_LEN (arg_sep ) == 0 ) {
107+ arg_sep = ZSTR_CHAR ('&' );
111108 }
112109 }
113110
@@ -189,7 +186,7 @@ PHPAPI void php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
189186 efree (index_int_as_str );
190187 }
191188 GC_TRY_PROTECT_RECURSION (ht );
192- php_url_encode_hash_ex (HASH_OF (zdata ), formstr , NULL , 0 , new_prefix , (Z_TYPE_P (zdata ) == IS_OBJECT ? zdata : NULL ), arg_sep , arg_sep_len , enc_type );
189+ php_url_encode_hash_ex (HASH_OF (zdata ), formstr , NULL , 0 , new_prefix , (Z_TYPE_P (zdata ) == IS_OBJECT ? zdata : NULL ), arg_sep , enc_type );
193190 GC_TRY_UNPROTECT_RECURSION (ht );
194191 zend_string_efree (new_prefix );
195192 } else if (Z_TYPE_P (zdata ) == IS_NULL || Z_TYPE_P (zdata ) == IS_RESOURCE ) {
@@ -201,7 +198,7 @@ PHPAPI void php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
201198 prop_name , prop_len ,
202199 num_prefix , num_prefix_len ,
203200 key_prefix ,
204- arg_sep , arg_sep_len );
201+ arg_sep );
205202 }
206203 } ZEND_HASH_FOREACH_END ();
207204}
@@ -214,16 +211,15 @@ PHP_FUNCTION(http_build_query)
214211 zval * formdata ;
215212 char * prefix = NULL ;
216213 size_t prefix_len = 0 ;
217- char * arg_sep = NULL ;
218- size_t arg_sep_len = 0 ;
214+ zend_string * arg_sep = NULL ;
219215 smart_str formstr = {0 };
220216 zend_long enc_type = PHP_QUERY_RFC1738 ;
221217
222218 ZEND_PARSE_PARAMETERS_START (1 , 4 )
223219 Z_PARAM_ARRAY_OR_OBJECT (formdata )
224220 Z_PARAM_OPTIONAL
225221 Z_PARAM_STRING (prefix , prefix_len )
226- Z_PARAM_STRING_OR_NULL (arg_sep , arg_sep_len )
222+ Z_PARAM_STR (arg_sep )
227223 Z_PARAM_LONG (enc_type )
228224 ZEND_PARSE_PARAMETERS_END ();
229225
@@ -232,7 +228,7 @@ PHP_FUNCTION(http_build_query)
232228 RETURN_THROWS ();
233229 }
234230
235- php_url_encode_hash_ex (HASH_OF (formdata ), & formstr , prefix , prefix_len , /* key_prefix */ NULL , (Z_TYPE_P (formdata ) == IS_OBJECT ? formdata : NULL ), arg_sep , arg_sep_len , (int )enc_type );
231+ php_url_encode_hash_ex (HASH_OF (formdata ), & formstr , prefix , prefix_len , /* key_prefix */ NULL , (Z_TYPE_P (formdata ) == IS_OBJECT ? formdata : NULL ), arg_sep , (int )enc_type );
236232
237233 RETURN_STR (smart_str_extract (& formstr ));
238234}
0 commit comments