diff options
| author | Dmitry Stogov <dmitry@zend.com> | 2013-07-31 17:36:06 +0400 | 
|---|---|---|
| committer | Dmitry Stogov <dmitry@zend.com> | 2013-07-31 17:36:06 +0400 | 
| commit | 4395f702074435edfbf44ddb5d82a7cd3ce82f01 (patch) | |
| tree | d59bd7e76914cb8c6934107e94021a2a25aaa75d /ext/soap/php_schema.c | |
| parent | fd8f45452032720d3239af2106434232c95249e2 (diff) | |
| download | php-git-4395f702074435edfbf44ddb5d82a7cd3ce82f01.tar.gz | |
Improved fix for bug #44686 (SOAP-ERROR: Parsing WSDL)
Diffstat (limited to 'ext/soap/php_schema.c')
| -rw-r--r-- | ext/soap/php_schema.c | 54 | 
1 files changed, 49 insertions, 5 deletions
| diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c index 7d2e129746..25bb177273 100644 --- a/ext/soap/php_schema.c +++ b/ext/soap/php_schema.c @@ -1081,6 +1081,14 @@ static int schema_group(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr groupType, sdlTyp  			nsptr = xmlSearchNs(groupType->doc, groupType, BAD_CAST(ns));  			if (nsptr != NULL) {  				smart_str_appends(&key, (char*)nsptr->href); +			} else { +				xmlAttrPtr ns = get_attribute(groupType->properties, "targetNamespace"); +				if (ns == NULL) { +					ns = tns; +				} +				if (ns) { +					smart_str_appends(&key, (char*)ns->children->content); +				}  			}  			smart_str_appendc(&key, ':');  			smart_str_appends(&key, type); @@ -1509,6 +1517,14 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr element, sdlTyp  			if (nsptr != NULL) {  				smart_str_appends(&nscat, (char*)nsptr->href);  				newType->namens = estrdup((char*)nsptr->href); +			} else { +				xmlAttrPtr ns = get_attribute(attrs, "targetNamespace"); +				if (ns == NULL) { +					ns = tns; +				} +				if (ns) { +					smart_str_appends(&nscat, (char*)ns->children->content); +				}  			}   			smart_str_appendc(&nscat, ':');  			smart_str_appends(&nscat, type); @@ -1735,6 +1751,14 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrType, sdl  			if (nsptr != NULL) {  				smart_str_appends(&key, (char*)nsptr->href);  				newAttr->namens = estrdup((char*)nsptr->href); +			} else { +				xmlAttrPtr ns = get_attribute(attrType->properties, "targetNamespace"); +				if (ns == NULL) { +					ns = tns; +				} +				if (ns) { +					smart_str_appends(&key, (char*)ns->children->content); +				}  			}  			smart_str_appendc(&key, ':');  			smart_str_appends(&key, attr_name); @@ -2036,13 +2060,31 @@ static void copy_extra_attribute(void *attribute)  	}  } +static void* schema_find_by_ref(HashTable *ht, char *ref) +{ +	void **tmp; + +	if (zend_hash_find(ht, ref, strlen(ref)+1, (void**)&tmp) == SUCCESS) { +		return tmp; +	} else { +		ref = strrchr(ref, ':'); +		if (ref) { +			if (zend_hash_find(ht, ref, strlen(ref)+1, (void**)&tmp) == SUCCESS) { +				return tmp; +			} +		} +	} +	return NULL; +} +  static void schema_attribute_fixup(sdlCtx *ctx, sdlAttributePtr attr)  {  	sdlAttributePtr *tmp;  	if (attr->ref != NULL) {  		if (ctx->attributes != NULL) { -			if (zend_hash_find(ctx->attributes, attr->ref, strlen(attr->ref)+1, (void**)&tmp) == SUCCESS) { +			tmp = (sdlAttributePtr*)schema_find_by_ref(ctx->attributes, attr->ref); +			if (tmp) {  				schema_attribute_fixup(ctx, *tmp);  				if ((*tmp)->name != NULL && attr->name == NULL) {  					attr->name = estrdup((*tmp)->name); @@ -2092,7 +2134,8 @@ static void schema_attributegroup_fixup(sdlCtx *ctx, sdlAttributePtr attr, HashT  	if (attr->ref != NULL) {  		if (ctx->attributeGroups != NULL) { -			if (zend_hash_find(ctx->attributeGroups, attr->ref, strlen(attr->ref)+1, (void**)&tmp) == SUCCESS) { +			tmp = (sdlTypePtr*)schema_find_by_ref(ctx->attributeGroups, attr->ref); +			if (tmp) {  				if ((*tmp)->attributes) {  					zend_hash_internal_pointer_reset((*tmp)->attributes);  					while (zend_hash_get_current_data((*tmp)->attributes,(void**)&tmp_attr) == SUCCESS) { @@ -2149,7 +2192,7 @@ static void schema_content_model_fixup(sdlCtx *ctx, sdlContentModelPtr model)  				model->kind = XSD_CONTENT_GROUP;  				model->u.group = (*tmp);  			} else { -				soap_error0(E_ERROR, "Parsing Schema: unresolved group 'ref' attribute"); +				soap_error1(E_ERROR, "Parsing Schema: unresolved group 'ref' attribute '%s'", model->u.group_ref);  			}  			break;  		} @@ -2193,7 +2236,8 @@ static void schema_type_fixup(sdlCtx *ctx, sdlTypePtr type)  	if (type->ref != NULL) {  		if (ctx->sdl->elements != NULL) { -			if (zend_hash_find(ctx->sdl->elements, type->ref, strlen(type->ref)+1, (void**)&tmp) == SUCCESS) { +			tmp = (sdlTypePtr*)schema_find_by_ref(ctx->sdl->elements, type->ref); +			if (tmp) {  				type->kind = (*tmp)->kind;  				type->encode = (*tmp)->encode;  				if ((*tmp)->nillable) { @@ -2209,7 +2253,7 @@ static void schema_type_fixup(sdlCtx *ctx, sdlTypePtr type)  			} else if (strcmp(type->ref, SCHEMA_NAMESPACE ":schema") == 0) {  				type->encode = get_conversion(XSD_ANYXML);  			} else { -				soap_error0(E_ERROR, "Parsing Schema: unresolved element 'ref' attribute"); +				soap_error1(E_ERROR, "Parsing Schema: unresolved element 'ref' attribute '%s'", type->ref);  			}  		}  		efree(type->ref); | 
