Skip to content

Commit df0b49e

Browse files
committed
wip
1 parent 00f1ba0 commit df0b49e

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
@@ -540,15 +540,20 @@ static zend_always_inline size_t php_url_encode_impl(unsigned char *to, const ch
540540
}
541541
/* }}} */
542542

543-
/* {{{ php_url_encode */
544-
PHPAPI zend_string *php_url_encode(char const *s, size_t len)
543+
static zend_always_inline zend_string *php_url_encode_helper(char const *s, size_t len, bool raw)
545544
{
546545
zend_string *result = zend_string_safe_alloc(3, len, 0, false);
547-
size_t length = php_url_encode_impl((unsigned char *) ZSTR_VAL(result), s, len, false);
546+
size_t length = php_url_encode_impl((unsigned char *) ZSTR_VAL(result), s, len, raw);
548547
ZSTR_VAL(result)[length] = '\0';
549548
ZEND_ASSERT(!ZSTR_IS_INTERNED(result) && GC_REFCOUNT(result) == 1);
550549
return zend_string_truncate(result, length, false);
551550
}
551+
552+
/* {{{ php_url_encode */
553+
PHPAPI zend_string *php_url_encode(char const *s, size_t len)
554+
{
555+
return php_url_encode_helper(s, len, false);
556+
}
552557
/* }}} */
553558

554559
/* {{{ URL-encodes string */
@@ -614,11 +619,7 @@ PHPAPI size_t php_url_decode(char *str, size_t len)
614619
/* {{{ php_raw_url_encode */
615620
PHPAPI zend_string *php_raw_url_encode(char const *s, size_t len)
616621
{
617-
zend_string *result = zend_string_safe_alloc(3, len, 0, false);
618-
size_t length = php_url_encode_impl((unsigned char *) ZSTR_VAL(result), s, len, true);
619-
ZSTR_VAL(result)[length] = '\0';
620-
ZEND_ASSERT(!ZSTR_IS_INTERNED(result) && GC_REFCOUNT(result) == 1);
621-
return zend_string_truncate(result, length, false);
622+
return php_url_encode_helper(s, len, true);
622623
}
623624
/* }}} */
624625

0 commit comments

Comments
 (0)