version 1.1.1.1, 2012/02/21 23:48:02
|
version 1.1.1.2, 2012/05/29 12:34:43
|
Line 29 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
Line 29 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
const char *num_prefix, int num_prefix_len, |
const char *num_prefix, int num_prefix_len, |
const char *key_prefix, int key_prefix_len, |
const char *key_prefix, int key_prefix_len, |
const char *key_suffix, int key_suffix_len, |
const char *key_suffix, int key_suffix_len, |
zval *type, char *arg_sep TSRMLS_DC) | zval *type, char *arg_sep, int enc_type TSRMLS_DC) |
{ |
{ |
char *key = NULL, *ekey, *newprefix, *p; | char *key = NULL; |
int arg_sep_len, key_len, ekey_len, key_type, newprefix_len; | char *ekey, *newprefix, *p; |
| int arg_sep_len, ekey_len, key_type, newprefix_len; |
| uint key_len; |
ulong idx; |
ulong idx; |
zval **zdata = NULL, *copyzval; |
zval **zdata = NULL, *copyzval; |
|
|
Line 64 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
Line 66 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
|
|
/* handling for private & protected object properties */ |
/* handling for private & protected object properties */ |
if (key && *key == '\0' && type != NULL) { |
if (key && *key == '\0' && type != NULL) { |
char *tmp; | const char *tmp; |
|
|
zend_object *zobj = zend_objects_get_address(type TSRMLS_CC); |
zend_object *zobj = zend_objects_get_address(type TSRMLS_CC); |
if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) != SUCCESS) { |
if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) != SUCCESS) { |
/* private or protected property access outside of the class */ |
/* private or protected property access outside of the class */ |
continue; |
continue; |
} |
} |
zend_unmangle_property_name(key, key_len-1, &tmp, &key); | zend_unmangle_property_name(key, key_len-1, &tmp, (const char**)&key); |
key_len = strlen(key); |
key_len = strlen(key); |
} |
} |
|
|
Line 81 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
Line 83 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
} |
} |
if (Z_TYPE_PP(zdata) == IS_ARRAY || Z_TYPE_PP(zdata) == IS_OBJECT) { |
if (Z_TYPE_PP(zdata) == IS_ARRAY || Z_TYPE_PP(zdata) == IS_OBJECT) { |
if (key_type == HASH_KEY_IS_STRING) { |
if (key_type == HASH_KEY_IS_STRING) { |
ekey = php_url_encode(key, key_len, &ekey_len); | if (enc_type == PHP_QUERY_RFC3986) { |
| ekey = php_raw_url_encode(key, key_len, &ekey_len); |
| } else { |
| ekey = php_url_encode(key, key_len, &ekey_len); |
| } |
newprefix_len = key_suffix_len + ekey_len + key_prefix_len + 3 /* %5B */; |
newprefix_len = key_suffix_len + ekey_len + key_prefix_len + 3 /* %5B */; |
newprefix = emalloc(newprefix_len + 1); |
newprefix = emalloc(newprefix_len + 1); |
p = newprefix; |
p = newprefix; |
Line 132 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
Line 138 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
*p = '\0'; |
*p = '\0'; |
} |
} |
ht->nApplyCount++; |
ht->nApplyCount++; |
php_url_encode_hash_ex(HASH_OF(*zdata), formstr, NULL, 0, newprefix, newprefix_len, "%5D", 3, (Z_TYPE_PP(zdata) == IS_OBJECT ? *zdata : NULL), arg_sep TSRMLS_CC); | php_url_encode_hash_ex(HASH_OF(*zdata), formstr, NULL, 0, newprefix, newprefix_len, "%5D", 3, (Z_TYPE_PP(zdata) == IS_OBJECT ? *zdata : NULL), arg_sep, enc_type TSRMLS_CC); |
ht->nApplyCount--; |
ht->nApplyCount--; |
efree(newprefix); |
efree(newprefix); |
} else if (Z_TYPE_PP(zdata) == IS_NULL || Z_TYPE_PP(zdata) == IS_RESOURCE) { |
} else if (Z_TYPE_PP(zdata) == IS_NULL || Z_TYPE_PP(zdata) == IS_RESOURCE) { |
Line 145 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
Line 151 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
/* Simple key=value */ |
/* Simple key=value */ |
smart_str_appendl(formstr, key_prefix, key_prefix_len); |
smart_str_appendl(formstr, key_prefix, key_prefix_len); |
if (key_type == HASH_KEY_IS_STRING) { |
if (key_type == HASH_KEY_IS_STRING) { |
ekey = php_url_encode(key, key_len, &ekey_len); | if (enc_type == PHP_QUERY_RFC3986) { |
| ekey = php_raw_url_encode(key, key_len, &ekey_len); |
| } else { |
| ekey = php_url_encode(key, key_len, &ekey_len); |
| } |
smart_str_appendl(formstr, ekey, ekey_len); |
smart_str_appendl(formstr, ekey, ekey_len); |
efree(ekey); |
efree(ekey); |
} else { |
} else { |
Line 161 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
Line 171 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
smart_str_appendl(formstr, "=", 1); |
smart_str_appendl(formstr, "=", 1); |
switch (Z_TYPE_PP(zdata)) { |
switch (Z_TYPE_PP(zdata)) { |
case IS_STRING: |
case IS_STRING: |
ekey = php_url_encode(Z_STRVAL_PP(zdata), Z_STRLEN_PP(zdata), &ekey_len); | if (enc_type == PHP_QUERY_RFC3986) { |
| ekey = php_raw_url_encode(Z_STRVAL_PP(zdata), Z_STRLEN_PP(zdata), &ekey_len); |
| } else { |
| ekey = php_url_encode(Z_STRVAL_PP(zdata), Z_STRLEN_PP(zdata), &ekey_len); |
| } |
break; |
break; |
case IS_LONG: |
case IS_LONG: |
case IS_BOOL: |
case IS_BOOL: |
Line 176 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
Line 190 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
*copyzval = **zdata; |
*copyzval = **zdata; |
zval_copy_ctor(copyzval); |
zval_copy_ctor(copyzval); |
convert_to_string_ex(©zval); |
convert_to_string_ex(©zval); |
ekey = php_url_encode(Z_STRVAL_P(copyzval), Z_STRLEN_P(copyzval), &ekey_len); | if (enc_type == PHP_QUERY_RFC3986) { |
| ekey = php_raw_url_encode(Z_STRVAL_P(copyzval), Z_STRLEN_P(copyzval), &ekey_len); |
| } else { |
| ekey = php_url_encode(Z_STRVAL_P(copyzval), Z_STRLEN_P(copyzval), &ekey_len); |
| } |
zval_ptr_dtor(©zval); |
zval_ptr_dtor(©zval); |
} |
} |
smart_str_appendl(formstr, ekey, ekey_len); |
smart_str_appendl(formstr, ekey, ekey_len); |
Line 188 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
Line 206 PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart
|
} |
} |
/* }}} */ |
/* }}} */ |
|
|
/* {{{ proto string http_build_query(mixed formdata [, string prefix [, string arg_separator]]) | /* {{{ proto string http_build_query(mixed formdata [, string prefix [, string arg_separator [, int enc_type]]]) |
Generates a form-encoded query string from an associative array or object. */ |
Generates a form-encoded query string from an associative array or object. */ |
PHP_FUNCTION(http_build_query) |
PHP_FUNCTION(http_build_query) |
{ |
{ |
Line 196 PHP_FUNCTION(http_build_query)
|
Line 214 PHP_FUNCTION(http_build_query)
|
char *prefix = NULL, *arg_sep=NULL; |
char *prefix = NULL, *arg_sep=NULL; |
int arg_sep_len = 0, prefix_len = 0; |
int arg_sep_len = 0, prefix_len = 0; |
smart_str formstr = {0}; |
smart_str formstr = {0}; |
| long enc_type = PHP_QUERY_RFC1738; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ss", &formdata, &prefix, &prefix_len, &arg_sep, &arg_sep_len) != SUCCESS) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ssl", &formdata, &prefix, &prefix_len, &arg_sep, &arg_sep_len, &enc_type) != SUCCESS) { |
RETURN_FALSE; |
RETURN_FALSE; |
} |
} |
|
|
Line 207 PHP_FUNCTION(http_build_query)
|
Line 225 PHP_FUNCTION(http_build_query)
|
RETURN_FALSE; |
RETURN_FALSE; |
} |
} |
|
|
if (php_url_encode_hash_ex(HASH_OF(formdata), &formstr, prefix, prefix_len, NULL, 0, NULL, 0, (Z_TYPE_P(formdata) == IS_OBJECT ? formdata : NULL), arg_sep TSRMLS_CC) == FAILURE) { | if (php_url_encode_hash_ex(HASH_OF(formdata), &formstr, prefix, prefix_len, NULL, 0, NULL, 0, (Z_TYPE_P(formdata) == IS_OBJECT ? formdata : NULL), arg_sep, enc_type TSRMLS_CC) == FAILURE) { |
if (formstr.c) { |
if (formstr.c) { |
efree(formstr.c); |
efree(formstr.c); |
} |
} |