Skip to content

Commit 4b46ed3

Browse files
committed
wip
1 parent 0f2be98 commit 4b46ed3

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

ext/standard/http.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ 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 || !*arg_sep) {
106+
if (!*arg_sep) {
107107
arg_sep = "&";
108108
arg_sep_len = 1;
109109
} else {

ext/standard/url.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -537,15 +537,20 @@ static zend_always_inline size_t php_url_encode_impl(unsigned char *to, const ch
537537
}
538538
/* }}} */
539539

540-
/* {{{ php_url_encode */
541-
PHPAPI zend_string *php_url_encode(char const *s, size_t len)
540+
static zend_always_inline zend_string *php_url_encode_helper(char const *s, size_t len, bool raw)
542541
{
543542
zend_string *result = zend_string_safe_alloc(3, len, 0, false);
544-
size_t length = php_url_encode_impl((unsigned char *) ZSTR_VAL(result), s, len, false);
543+
size_t length = php_url_encode_impl((unsigned char *) ZSTR_VAL(result), s, len, raw);
545544
ZSTR_VAL(result)[length] = '\0';
546545
ZEND_ASSERT(!ZSTR_IS_INTERNED(result) && GC_REFCOUNT(result) == 1);
547546
return zend_string_truncate(result, length, false);
548547
}
548+
549+
/* {{{ php_url_encode */
550+
PHPAPI zend_string *php_url_encode(char const *s, size_t len)
551+
{
552+
return php_url_encode_helper(s, len, false);
553+
}
549554
/* }}} */
550555

551556
/* {{{ URL-encodes string */
@@ -606,11 +611,7 @@ PHPAPI size_t php_url_decode(char *str, size_t len)
606611
/* {{{ php_raw_url_encode */
607612
PHPAPI zend_string *php_raw_url_encode(char const *s, size_t len)
608613
{
609-
zend_string *result = zend_string_safe_alloc(3, len, 0, false);
610-
size_t length = php_url_encode_impl((unsigned char *) ZSTR_VAL(result), s, len, true);
611-
ZSTR_VAL(result)[length] = '\0';
612-
ZEND_ASSERT(!ZSTR_IS_INTERNED(result) && GC_REFCOUNT(result) == 1);
613-
return zend_string_truncate(result, length, false);
614+
return php_url_encode_helper(s, len, true);
614615
}
615616
/* }}} */
616617

0 commit comments

Comments
 (0)