diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 3d796252eb7..621c905a555 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -841,6 +841,7 @@ try_again: zval *data; zend_string *key; has_cookies = 1; + bool first_cookie = true; smart_str_append_const(&soap_headers, "Cookie: "); ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(cookies), key, data) { if (key && Z_TYPE_P(data) == IS_ARRAY) { @@ -856,10 +857,13 @@ try_again: Z_TYPE_P(tmp) != IS_STRING || in_domain(ZSTR_VAL(phpurl->host),Z_STRVAL_P(tmp))) && (use_ssl || (tmp = zend_hash_index_find(Z_ARRVAL_P(data), 3)) == NULL)) { + if (!first_cookie) { + smart_str_appends(&soap_headers, "; "); + } + first_cookie = false; smart_str_append(&soap_headers, key); smart_str_appendc(&soap_headers, '='); smart_str_append(&soap_headers, Z_STR_P(value)); - smart_str_appendc(&soap_headers, ';'); } } } diff --git a/ext/soap/tests/bugs/bug76232.phpt b/ext/soap/tests/bugs/bug76232.phpt new file mode 100644 index 00000000000..58db3c57d58 --- /dev/null +++ b/ext/soap/tests/bugs/bug76232.phpt @@ -0,0 +1,67 @@ +--TEST-- +Bug #76232 (SoapClient Cookie Header Semicolon) +--EXTENSIONS-- +soap +--SKIPIF-- + +--FILE-- + 'http://' . PHP_CLI_SERVER_ADDRESS, + 'uri' => 'misc-uri', + 'trace' => true, +]); + +echo "=== Request with one cookie ===\n"; + +$client->__setCookie('testcookie1', 'true'); +$client->__soapCall("foo", []); +echo $client->__getLastRequestHeaders(); + +echo "=== Request with two cookies ===\n"; + +$client->__setCookie('testcookie2', 'true'); +$client->__soapCall("foo", []); + +echo $client->__getLastRequestHeaders(); +?> +--EXPECTF-- +=== Request with one cookie === +POST / HTTP/1.1 +Host: %s +Connection: Keep-Alive +User-Agent: PHP-SOAP/%s +Content-Type: text/xml; charset=utf-8 +SOAPAction: "misc-uri#foo" +Content-Length: %d +Cookie: testcookie1=true + +=== Request with two cookies === +POST / HTTP/1.1 +Host: %s +Connection: Keep-Alive +User-Agent: PHP-SOAP/%s +Content-Type: text/xml; charset=utf-8 +SOAPAction: "misc-uri#foo" +Content-Length: %d +Cookie: testcookie1=true; testcookie2=true