@@ -27,10 +27,10 @@ static void php_url_encode_scalar(zval *scalar, smart_str *form_str,
27
27
const char * index_string , size_t index_string_len ,
28
28
const char * num_prefix , size_t num_prefix_len ,
29
29
const zend_string * key_prefix ,
30
- const char * arg_sep , size_t arg_sep_len )
30
+ const zend_string * arg_sep )
31
31
{
32
32
if (form_str -> s ) {
33
- smart_str_appendl (form_str , arg_sep , arg_sep_len );
33
+ smart_str_append (form_str , arg_sep );
34
34
}
35
35
/* Simple key=value */
36
36
if (key_prefix ) {
@@ -87,7 +87,7 @@ static void php_url_encode_scalar(zval *scalar, smart_str *form_str,
87
87
PHPAPI void php_url_encode_hash_ex (HashTable * ht , smart_str * formstr ,
88
88
const char * num_prefix , size_t num_prefix_len ,
89
89
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 )
91
91
{
92
92
zend_string * key = NULL ;
93
93
const char * prop_name ;
@@ -103,11 +103,8 @@ PHPAPI void php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
103
103
104
104
if (!arg_sep ) {
105
105
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 ('&' );
111
108
}
112
109
}
113
110
@@ -189,7 +186,7 @@ PHPAPI void php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
189
186
efree (index_int_as_str );
190
187
}
191
188
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 );
193
190
GC_TRY_UNPROTECT_RECURSION (ht );
194
191
zend_string_efree (new_prefix );
195
192
} 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,
201
198
prop_name , prop_len ,
202
199
num_prefix , num_prefix_len ,
203
200
key_prefix ,
204
- arg_sep , arg_sep_len );
201
+ arg_sep );
205
202
}
206
203
} ZEND_HASH_FOREACH_END ();
207
204
}
@@ -214,16 +211,15 @@ PHP_FUNCTION(http_build_query)
214
211
zval * formdata ;
215
212
char * prefix = NULL ;
216
213
size_t prefix_len = 0 ;
217
- char * arg_sep = NULL ;
218
- size_t arg_sep_len = 0 ;
214
+ zend_string * arg_sep = NULL ;
219
215
smart_str formstr = {0 };
220
216
zend_long enc_type = PHP_QUERY_RFC1738 ;
221
217
222
218
ZEND_PARSE_PARAMETERS_START (1 , 4 )
223
219
Z_PARAM_ARRAY_OR_OBJECT (formdata )
224
220
Z_PARAM_OPTIONAL
225
221
Z_PARAM_STRING (prefix , prefix_len )
226
- Z_PARAM_STRING_OR_NULL (arg_sep , arg_sep_len )
222
+ Z_PARAM_STR (arg_sep )
227
223
Z_PARAM_LONG (enc_type )
228
224
ZEND_PARSE_PARAMETERS_END ();
229
225
@@ -232,7 +228,7 @@ PHP_FUNCTION(http_build_query)
232
228
RETURN_THROWS ();
233
229
}
234
230
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 );
236
232
237
233
RETURN_STR (smart_str_extract (& formstr ));
238
234
}
0 commit comments