Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ext/soap/php_http.c: Refactor cookies loop in make_http_soap_request()
  • Loading branch information
Girgias committed Jul 7, 2025
commit 239ebf2001c205af634d98df83dfe2dc12f84e62
51 changes: 30 additions & 21 deletions ext/soap/php_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,28 +870,37 @@ bool make_http_soap_request(
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) {
zval *value;

if ((value = zend_hash_index_find(Z_ARRVAL_P(data), 0)) != NULL &&
Z_TYPE_P(value) == IS_STRING) {
zval *tmp;
if (((tmp = zend_hash_index_find(Z_ARRVAL_P(data), 1)) == NULL ||
Z_TYPE_P(tmp) != IS_STRING ||
strncmp(phpurl->path?ZSTR_VAL(phpurl->path):"/",Z_STRVAL_P(tmp),Z_STRLEN_P(tmp)) == 0) &&
((tmp = zend_hash_index_find(Z_ARRVAL_P(data), 2)) == NULL ||
Z_TYPE_P(tmp) != IS_STRING ||
in_domain(phpurl->host, Z_STR_P(tmp))) &&
(use_ssl || (tmp = zend_hash_index_find(Z_ARRVAL_P(data), 3)) == NULL)) {
if (!first_cookie) {
smart_str_append_const(&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));
}
if (key == NULL || Z_TYPE_P(data) != IS_ARRAY) {
continue;
}

zval *value = zend_hash_index_find(Z_ARRVAL_P(data), 0);
if (value == NULL || Z_TYPE_P(value) != IS_STRING) {
continue;
}

zval *tmp;
if (
(
(tmp = zend_hash_index_find(Z_ARRVAL_P(data), 1)) == NULL
|| Z_TYPE_P(tmp) != IS_STRING
|| strncmp(phpurl->path?ZSTR_VAL(phpurl->path):"/",Z_STRVAL_P(tmp),Z_STRLEN_P(tmp)) == 0
) && (
(tmp = zend_hash_index_find(Z_ARRVAL_P(data), 2)) == NULL
|| Z_TYPE_P(tmp) != IS_STRING
|| in_domain(phpurl->host, Z_STR_P(tmp))
) && (
use_ssl
|| (tmp = zend_hash_index_find(Z_ARRVAL_P(data), 3)) == NULL
)
) {
if (!first_cookie) {
smart_str_append_const(&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));
}
} ZEND_HASH_FOREACH_END();
smart_str_append_const(&soap_headers, "\r\n");
Expand Down