@@ -1685,25 +1685,25 @@ static void php_cli_server_client_save_header(php_cli_server_client *client)
1685
1685
GC_MAKE_PERSISTENT_LOCAL (lc_header_name );
1686
1686
1687
1687
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 " );
1689
1689
1690
1690
/**
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.
1693
1693
**/
1694
- if ((entry == NULL && is_forwarded_header ) || !is_forwarded_header ) {
1694
+ if ((entry == NULL && with_comma ) || !with_comma ) {
1695
1695
ZVAL_STR (& tmp , client -> current_header_value );
1696
1696
1697
1697
/* Add the wrapped zend_string to the HashTable */
1698
1698
zend_hash_add (& client -> request .headers , lc_header_name , & tmp );
1699
1699
zend_hash_add (& client -> request .headers_original_case , client -> current_header_name , & tmp );
1700
1700
} else {
1701
1701
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);
1703
1703
1704
1704
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 );
1707
1707
1708
1708
ZVAL_STR (& tmp , newval );
1709
1709
0 commit comments