From: Dmitry Stogov Date: Mon, 2 Feb 2004 17:39:10 +0000 (+0000) Subject: fix: proper handling of SOAP 1.1 href and unresolved attributes references X-Git-Tag: php-5.0.0b4RC1~188 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a70a620a01897579ab7d28418532a55dcfb6c459;p=php fix: proper handling of SOAP 1.1 href and unresolved attributes references --- diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 2e9eb23b06..12d0ca0395 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -2304,7 +2304,14 @@ xmlNodePtr sdl_guess_convert_xml(encodeTypePtr enc, zval *data, int style, xmlNo static xmlNodePtr check_and_resolve_href(xmlNodePtr data) { if (data && data->properties) { - xmlAttrPtr href = get_attribute(data->properties, "href"); + xmlAttrPtr href; + + href = data->properties; + while (1) { + href = get_attribute(href, "href"); + if (href == NULL || href->ns == NULL) {break;} + href = href->next; + } if (href) { /* Internal href try and find node */ if (href->children->content[0] == '#') { diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c index 69372c39ce..cde1a8ef86 100644 --- a/ext/soap/php_schema.c +++ b/ext/soap/php_schema.c @@ -2009,6 +2009,13 @@ static void schema_attribute_fixup(sdlPtr sdl, sdlAttributePtr attr) } attr->encode = (*tmp)->encode; } + } + if (attr->name == NULL && attr->ref != NULL) { + char *name, *ns; + parse_namespace(attr->ref, &name, &ns); + attr->name = strdup(name); + if (name) {efree(name);} + if (ns) {efree(ns);} } efree(attr->ref); attr->ref = NULL; diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c index 65e058c2bf..0f03d19fa7 100644 --- a/ext/soap/php_xml.c +++ b/ext/soap/php_xml.c @@ -182,7 +182,7 @@ xmlNodePtr get_node_with_attribute_recursive_ex(xmlNodePtr node, char *name, cha int parse_namespace(const char *inval, char **value, char **namespace) { - char *found = strchr(inval, ':'); + char *found = strrchr(inval, ':'); if (found != NULL && found != inval) { (*namespace) = estrndup(inval, found - inval); diff --git a/ext/soap/tests/soap12/T75.phpt b/ext/soap/tests/soap12/T75.phpt new file mode 100644 index 0000000000..3e2166d957 --- /dev/null +++ b/ext/soap/tests/soap12/T75.phpt @@ -0,0 +1,28 @@ +--TEST-- +SOAP 1.2: T75 echoResolvedRef +--SKIPIF-- + +--FILE-- + + + + + + + + + + +EOF; +include "soap12-test.inc"; +?> +--EXPECT-- + +http://example.org/today/new.xml +ok diff --git a/ext/soap/tests/soap12/soap12-test.inc b/ext/soap/tests/soap12/soap12-test.inc index 47f39e2b41..7d0033da56 100644 --- a/ext/soap/tests/soap12/soap12-test.inc +++ b/ext/soap/tests/soap12/soap12-test.inc @@ -107,6 +107,10 @@ class Soap12test { function echoHeader() { return $this->header; } + + function echoResolvedRef($ref) { + return $ref->RelativeReference->base.$ref->RelativeReference->href; + } } $server = new soapserver("http://http://example.org/ts-tests","http://example.org/ts-tests/C"); diff --git a/ext/soap/tests/soap12/soap12-test.wsdl b/ext/soap/tests/soap12/soap12-test.wsdl index 83a6423176..8993cf5b5e 100644 --- a/ext/soap/tests/soap12/soap12-test.wsdl +++ b/ext/soap/tests/soap12/soap12-test.wsdl @@ -331,6 +331,13 @@ + + + + + + + @@ -355,6 +362,10 @@ + + + + @@ -501,8 +512,6 @@ - - @@ -517,6 +526,15 @@ + + + + + + + + +