Skip to content

Commit ba59dc3

Browse files
committed
Soap: Split up an if condition into a nested if
This is in preparation for adding functionality in later commits.
1 parent 2c3c238 commit ba59dc3

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

ext/soap/soap.c

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,34 +1346,32 @@ PHP_METHOD(SoapServer, handle)
13461346
zend_string *server = ZSTR_KNOWN(ZEND_STR_AUTOGLOBAL_SERVER);
13471347

13481348
zend_is_auto_global(server);
1349-
if ((server_vars = zend_hash_find(&EG(symbol_table), server)) != NULL &&
1350-
Z_TYPE_P(server_vars) == IS_ARRAY &&
1351-
(encoding = zend_hash_str_find(Z_ARRVAL_P(server_vars), "HTTP_CONTENT_ENCODING", sizeof("HTTP_CONTENT_ENCODING")-1)) != NULL &&
1352-
Z_TYPE_P(encoding) == IS_STRING) {
1353-
1354-
if (zend_string_equals_literal(Z_STR_P(encoding), "gzip")
1355-
|| zend_string_equals_literal(Z_STR_P(encoding), "x-gzip")
1356-
|| zend_string_equals_literal(Z_STR_P(encoding), "deflate")
1357-
) {
1358-
zval filter_params;
1359-
1360-
array_init_size(&filter_params, 1);
1361-
add_assoc_long_ex(&filter_params, "window", sizeof("window")-1, 0x2f); /* ANY WBITS */
1362-
1363-
zf = php_stream_filter_create("zlib.inflate", &filter_params, 0);
1364-
zend_array_destroy(Z_ARR(filter_params));
1365-
1366-
if (zf) {
1367-
php_stream_filter_append(&SG(request_info).request_body->readfilters, zf);
1349+
if ((server_vars = zend_hash_find(&EG(symbol_table), server)) != NULL && Z_TYPE_P(server_vars) == IS_ARRAY) {
1350+
if ((encoding = zend_hash_str_find(Z_ARRVAL_P(server_vars), "HTTP_CONTENT_ENCODING", sizeof("HTTP_CONTENT_ENCODING")-1)) != NULL && Z_TYPE_P(encoding) == IS_STRING) {
1351+
if (zend_string_equals_literal(Z_STR_P(encoding), "gzip")
1352+
|| zend_string_equals_literal(Z_STR_P(encoding), "x-gzip")
1353+
|| zend_string_equals_literal(Z_STR_P(encoding), "deflate")
1354+
) {
1355+
zval filter_params;
1356+
1357+
array_init_size(&filter_params, 1);
1358+
add_assoc_long_ex(&filter_params, "window", sizeof("window")-1, 0x2f); /* ANY WBITS */
1359+
1360+
zf = php_stream_filter_create("zlib.inflate", &filter_params, 0);
1361+
zend_array_destroy(Z_ARR(filter_params));
1362+
1363+
if (zf) {
1364+
php_stream_filter_append(&SG(request_info).request_body->readfilters, zf);
1365+
} else {
1366+
php_error_docref(NULL, E_WARNING,"Can't uncompress compressed request");
1367+
SOAP_SERVER_END_CODE();
1368+
return;
1369+
}
13681370
} else {
1369-
php_error_docref(NULL, E_WARNING,"Can't uncompress compressed request");
1371+
php_error_docref(NULL, E_WARNING,"Request is compressed with unknown compression '%s'",Z_STRVAL_P(encoding));
13701372
SOAP_SERVER_END_CODE();
13711373
return;
13721374
}
1373-
} else {
1374-
php_error_docref(NULL, E_WARNING,"Request is compressed with unknown compression '%s'",Z_STRVAL_P(encoding));
1375-
SOAP_SERVER_END_CODE();
1376-
return;
13771375
}
13781376
}
13791377

0 commit comments

Comments
 (0)