Skip to content

Commit 3a20062

Browse files
committed
changes fro feedback
1 parent 9b21b78 commit 3a20062

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

sapi/cli/php_cli_server.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,25 +1685,25 @@ static void php_cli_server_client_save_header(php_cli_server_client *client)
16851685
GC_MAKE_PERSISTENT_LOCAL(lc_header_name);
16861686

16871687
zval *entry = zend_hash_find(&client->request.headers, lc_header_name);
1688-
bool is_forwarded_header = strstr(ZSTR_VAL(lc_header_name), "forwarded");
1688+
bool with_comma = !zend_string_equals_literal(lc_header_name, "set-cookie");
16891689

16901690
/**
1691-
* **Forwarded** HTTP family headers can have 1 or more values separated by a comma while still
1692-
* possibly be set separately by the client.
1691+
* `Set-Cookie` HTTP header being the exception, they can have 1 or more values separated
1692+
* by a comma while still possibly be set separately by the client.
16931693
**/
1694-
if ((entry == NULL && is_forwarded_header) || !is_forwarded_header) {
1694+
if ((entry == NULL && with_comma) || !with_comma) {
16951695
ZVAL_STR(&tmp, client->current_header_value);
16961696

16971697
/* Add the wrapped zend_string to the HashTable */
16981698
zend_hash_add(&client->request.headers, lc_header_name, &tmp);
16991699
zend_hash_add(&client->request.headers_original_case, client->current_header_name, &tmp);
17001700
} else {
17011701
zend_string *curval = Z_STR_P(entry);
1702-
zend_string *newval = zend_string_alloc(ZSTR_LEN(curval) + ZSTR_LEN(client->current_header_value) + 2, /* persistent */true);
1702+
zend_string *newval = zend_string_alloc(ZSTR_LEN(curval) + ZSTR_LEN(client->current_header_value) + 3, /* persistent */true);
17031703

17041704
memcpy(ZSTR_VAL(newval), ZSTR_VAL(curval), ZSTR_LEN(curval));
1705-
memcpy(ZSTR_VAL(newval) + ZSTR_LEN(curval), ",", 1);
1706-
memcpy(ZSTR_VAL(newval) + ZSTR_LEN(curval) + 1, ZSTR_VAL(client->current_header_value), ZSTR_LEN(client->current_header_value) + 1);
1705+
memcpy(ZSTR_VAL(newval) + ZSTR_LEN(curval), ", ", 2);
1706+
memcpy(ZSTR_VAL(newval) + ZSTR_LEN(curval) + 2, ZSTR_VAL(client->current_header_value), ZSTR_LEN(client->current_header_value) + 1);
17071707

17081708
ZVAL_STR(&tmp, newval);
17091709

sapi/cli/tests/gh16137.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ $ctx = stream_context_create(array('http' => array (
1717
var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, true, $ctx));
1818
?>
1919
--EXPECT--
20-
string(23) "127.0.0.1,192.168.1.254"
20+
string(24) "127.0.0.1, 192.168.1.254"

0 commit comments

Comments
 (0)