ext/soap: Reduce scope and use proper names for XML attribute variables

This commit is contained in:
Gina Peter Banyard 2024-10-16 16:16:16 +01:00
parent 617136296c
commit d48bc086d3

View file

@ -528,29 +528,28 @@ static sdlSoapBindingFunctionHeaderPtr wsdl_soap_binding_header(sdlCtx* ctx, xml
static void wsdl_soap_binding_body(sdlCtx* ctx, xmlNodePtr node, char* wsdl_soap_namespace, sdlSoapBindingFunctionBody *binding, HashTable* params) static void wsdl_soap_binding_body(sdlCtx* ctx, xmlNodePtr node, char* wsdl_soap_namespace, sdlSoapBindingFunctionBody *binding, HashTable* params)
{ {
xmlNodePtr trav; xmlNodePtr trav;
xmlAttrPtr tmp;
trav = node->children; trav = node->children;
while (trav != NULL) { while (trav != NULL) {
if (node_is_equal_ex(trav, "body", wsdl_soap_namespace)) { if (node_is_equal_ex(trav, "body", wsdl_soap_namespace)) {
xmlNodePtr body = trav; xmlNodePtr body = trav;
tmp = get_attribute(body->properties, "use"); xmlAttrPtr useAttribute = get_attribute(body->properties, "use");
if (tmp && !strncmp((char*)tmp->children->content, "literal", sizeof("literal"))) { if (useAttribute && !strncmp((char*)useAttribute->children->content, "literal", sizeof("literal"))) {
binding->use = SOAP_LITERAL; binding->use = SOAP_LITERAL;
} else { } else {
binding->use = SOAP_ENCODED; binding->use = SOAP_ENCODED;
} }
tmp = get_attribute(body->properties, "namespace"); xmlAttrPtr namespaceAttribute = get_attribute(body->properties, "namespace");
if (tmp) { if (namespaceAttribute) {
binding->ns = estrdup((char*)tmp->children->content); binding->ns = estrdup((char*)namespaceAttribute->children->content);
} }
tmp = get_attribute(body->properties, "parts"); xmlAttrPtr partsAttribute = get_attribute(body->properties, "parts");
if (tmp) { if (partsAttribute) {
HashTable ht; HashTable ht;
char *parts = (char*)tmp->children->content; char *parts = (char*)partsAttribute->children->content;
/* Delete all parts those are not in the "parts" attribute */ /* Delete all parts those are not in the "parts" attribute */
zend_hash_init(&ht, 0, NULL, delete_parameter, 0); zend_hash_init(&ht, 0, NULL, delete_parameter, 0);
@ -585,14 +584,14 @@ static void wsdl_soap_binding_body(sdlCtx* ctx, xmlNodePtr node, char* wsdl_soap
} }
if (binding->use == SOAP_ENCODED) { if (binding->use == SOAP_ENCODED) {
tmp = get_attribute(body->properties, "encodingStyle"); xmlAttrPtr encodingStyleAttribute = get_attribute(body->properties, "encodingStyle");
if (tmp) { if (encodingStyleAttribute) {
if (strncmp((char*)tmp->children->content, SOAP_1_1_ENC_NAMESPACE, sizeof(SOAP_1_1_ENC_NAMESPACE)) == 0) { if (strncmp((char*)encodingStyleAttribute->children->content, SOAP_1_1_ENC_NAMESPACE, sizeof(SOAP_1_1_ENC_NAMESPACE)) == 0) {
binding->encodingStyle = SOAP_ENCODING_1_1; binding->encodingStyle = SOAP_ENCODING_1_1;
} else if (strncmp((char*)tmp->children->content, SOAP_1_2_ENC_NAMESPACE, sizeof(SOAP_1_2_ENC_NAMESPACE)) == 0) { } else if (strncmp((char*)encodingStyleAttribute->children->content, SOAP_1_2_ENC_NAMESPACE, sizeof(SOAP_1_2_ENC_NAMESPACE)) == 0) {
binding->encodingStyle = SOAP_ENCODING_1_2; binding->encodingStyle = SOAP_ENCODING_1_2;
} else { } else {
soap_error1(E_ERROR, "Parsing WSDL: Unknown encodingStyle '%s'", tmp->children->content); soap_error1(E_ERROR, "Parsing WSDL: Unknown encodingStyle '%s'", encodingStyleAttribute->children->content);
} }
} else { } else {
soap_error0(E_ERROR, "Parsing WSDL: Unspecified encodingStyle"); soap_error0(E_ERROR, "Parsing WSDL: Unspecified encodingStyle");