Skip to content

Commit 239ebf2

Browse files
committed
ext/soap/php_http.c: Refactor cookies loop in make_http_soap_request()
1 parent ca16a22 commit 239ebf2

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

ext/soap/php_http.c

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -870,28 +870,37 @@ bool make_http_soap_request(
870870
bool first_cookie = true;
871871
smart_str_append_const(&soap_headers, "Cookie: ");
872872
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(cookies), key, data) {
873-
if (key && Z_TYPE_P(data) == IS_ARRAY) {
874-
zval *value;
875-
876-
if ((value = zend_hash_index_find(Z_ARRVAL_P(data), 0)) != NULL &&
877-
Z_TYPE_P(value) == IS_STRING) {
878-
zval *tmp;
879-
if (((tmp = zend_hash_index_find(Z_ARRVAL_P(data), 1)) == NULL ||
880-
Z_TYPE_P(tmp) != IS_STRING ||
881-
strncmp(phpurl->path?ZSTR_VAL(phpurl->path):"/",Z_STRVAL_P(tmp),Z_STRLEN_P(tmp)) == 0) &&
882-
((tmp = zend_hash_index_find(Z_ARRVAL_P(data), 2)) == NULL ||
883-
Z_TYPE_P(tmp) != IS_STRING ||
884-
in_domain(phpurl->host, Z_STR_P(tmp))) &&
885-
(use_ssl || (tmp = zend_hash_index_find(Z_ARRVAL_P(data), 3)) == NULL)) {
886-
if (!first_cookie) {
887-
smart_str_append_const(&soap_headers, "; ");
888-
}
889-
first_cookie = false;
890-
smart_str_append(&soap_headers, key);
891-
smart_str_appendc(&soap_headers, '=');
892-
smart_str_append(&soap_headers, Z_STR_P(value));
893-
}
873+
if (key == NULL || Z_TYPE_P(data) != IS_ARRAY) {
874+
continue;
875+
}
876+
877+
zval *value = zend_hash_index_find(Z_ARRVAL_P(data), 0);
878+
if (value == NULL || Z_TYPE_P(value) != IS_STRING) {
879+
continue;
880+
}
881+
882+
zval *tmp;
883+
if (
884+
(
885+
(tmp = zend_hash_index_find(Z_ARRVAL_P(data), 1)) == NULL
886+
|| Z_TYPE_P(tmp) != IS_STRING
887+
|| strncmp(phpurl->path?ZSTR_VAL(phpurl->path):"/",Z_STRVAL_P(tmp),Z_STRLEN_P(tmp)) == 0
888+
) && (
889+
(tmp = zend_hash_index_find(Z_ARRVAL_P(data), 2)) == NULL
890+
|| Z_TYPE_P(tmp) != IS_STRING
891+
|| in_domain(phpurl->host, Z_STR_P(tmp))
892+
) && (
893+
use_ssl
894+
|| (tmp = zend_hash_index_find(Z_ARRVAL_P(data), 3)) == NULL
895+
)
896+
) {
897+
if (!first_cookie) {
898+
smart_str_append_const(&soap_headers, "; ");
894899
}
900+
first_cookie = false;
901+
smart_str_append(&soap_headers, key);
902+
smart_str_appendc(&soap_headers, '=');
903+
smart_str_append(&soap_headers, Z_STR_P(value));
895904
}
896905
} ZEND_HASH_FOREACH_END();
897906
smart_str_append_const(&soap_headers, "\r\n");

0 commit comments

Comments
 (0)