mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Deduplicate URI building code in soap schema code (#15799)
This commit is contained in:
parent
6ed730eb59
commit
b7b492b184
3 changed files with 22 additions and 35 deletions
|
@ -143,6 +143,22 @@ static void schema_load_file(sdlCtx *ctx, xmlAttrPtr ns, xmlChar *location, xmlA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returned uri must be freed by the caller. */
|
||||||
|
xmlChar *schema_location_construct_uri(const xmlAttr *attribute)
|
||||||
|
{
|
||||||
|
xmlChar *uri;
|
||||||
|
xmlChar *base = xmlNodeGetBase(attribute->doc, attribute->parent);
|
||||||
|
|
||||||
|
if (base == NULL) {
|
||||||
|
uri = xmlBuildURI(attribute->children->content, attribute->doc->URL);
|
||||||
|
} else {
|
||||||
|
uri = xmlBuildURI(attribute->children->content, base);
|
||||||
|
xmlFree(base);
|
||||||
|
}
|
||||||
|
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
2.6.1 xsi:type
|
2.6.1 xsi:type
|
||||||
2.6.2 xsi:nil
|
2.6.2 xsi:nil
|
||||||
|
@ -196,15 +212,7 @@ int load_schema(sdlCtx *ctx, xmlNodePtr schema)
|
||||||
if (location == NULL) {
|
if (location == NULL) {
|
||||||
soap_error0(E_ERROR, "Parsing Schema: include has no 'schemaLocation' attribute");
|
soap_error0(E_ERROR, "Parsing Schema: include has no 'schemaLocation' attribute");
|
||||||
} else {
|
} else {
|
||||||
xmlChar *uri;
|
xmlChar *uri = schema_location_construct_uri(location);
|
||||||
xmlChar *base = xmlNodeGetBase(trav->doc, trav);
|
|
||||||
|
|
||||||
if (base == NULL) {
|
|
||||||
uri = xmlBuildURI(location->children->content, trav->doc->URL);
|
|
||||||
} else {
|
|
||||||
uri = xmlBuildURI(location->children->content, base);
|
|
||||||
xmlFree(base);
|
|
||||||
}
|
|
||||||
schema_load_file(ctx, NULL, uri, tns, 0);
|
schema_load_file(ctx, NULL, uri, tns, 0);
|
||||||
xmlFree(uri);
|
xmlFree(uri);
|
||||||
}
|
}
|
||||||
|
@ -216,15 +224,7 @@ int load_schema(sdlCtx *ctx, xmlNodePtr schema)
|
||||||
if (location == NULL) {
|
if (location == NULL) {
|
||||||
soap_error0(E_ERROR, "Parsing Schema: redefine has no 'schemaLocation' attribute");
|
soap_error0(E_ERROR, "Parsing Schema: redefine has no 'schemaLocation' attribute");
|
||||||
} else {
|
} else {
|
||||||
xmlChar *uri;
|
xmlChar *uri = schema_location_construct_uri(location);
|
||||||
xmlChar *base = xmlNodeGetBase(trav->doc, trav);
|
|
||||||
|
|
||||||
if (base == NULL) {
|
|
||||||
uri = xmlBuildURI(location->children->content, trav->doc->URL);
|
|
||||||
} else {
|
|
||||||
uri = xmlBuildURI(location->children->content, base);
|
|
||||||
xmlFree(base);
|
|
||||||
}
|
|
||||||
schema_load_file(ctx, NULL, uri, tns, 0);
|
schema_load_file(ctx, NULL, uri, tns, 0);
|
||||||
xmlFree(uri);
|
xmlFree(uri);
|
||||||
/* TODO: <redefine> support */
|
/* TODO: <redefine> support */
|
||||||
|
@ -245,14 +245,7 @@ int load_schema(sdlCtx *ctx, xmlNodePtr schema)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (location) {
|
if (location) {
|
||||||
xmlChar *base = xmlNodeGetBase(trav->doc, trav);
|
uri = schema_location_construct_uri(location);
|
||||||
|
|
||||||
if (base == NULL) {
|
|
||||||
uri = xmlBuildURI(location->children->content, trav->doc->URL);
|
|
||||||
} else {
|
|
||||||
uri = xmlBuildURI(location->children->content, base);
|
|
||||||
xmlFree(base);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
schema_load_file(ctx, ns, uri, tns, 1);
|
schema_load_file(ctx, ns, uri, tns, 1);
|
||||||
if (uri != NULL) {xmlFree(uri);}
|
if (uri != NULL) {xmlFree(uri);}
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
int load_schema(sdlCtx *ctx, xmlNodePtr schema);
|
int load_schema(sdlCtx *ctx, xmlNodePtr schema);
|
||||||
void schema_pass2(sdlCtx *ctx);
|
void schema_pass2(sdlCtx *ctx);
|
||||||
|
|
||||||
|
xmlChar *schema_location_construct_uri(const xmlAttr *attribute);
|
||||||
|
|
||||||
void delete_model(zval *zv);
|
void delete_model(zval *zv);
|
||||||
void delete_model_persistent(zval *zv);
|
void delete_model_persistent(zval *zv);
|
||||||
void delete_type(zval *zv);
|
void delete_type(zval *zv);
|
||||||
|
|
|
@ -361,15 +361,7 @@ static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, int include)
|
||||||
/* TODO: namespace ??? */
|
/* TODO: namespace ??? */
|
||||||
xmlAttrPtr tmp = get_attribute(trav->properties, "location");
|
xmlAttrPtr tmp = get_attribute(trav->properties, "location");
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
xmlChar *uri;
|
xmlChar *uri = schema_location_construct_uri(tmp);
|
||||||
xmlChar *base = xmlNodeGetBase(trav->doc, trav);
|
|
||||||
|
|
||||||
if (base == NULL) {
|
|
||||||
uri = xmlBuildURI(tmp->children->content, trav->doc->URL);
|
|
||||||
} else {
|
|
||||||
uri = xmlBuildURI(tmp->children->content, base);
|
|
||||||
xmlFree(base);
|
|
||||||
}
|
|
||||||
load_wsdl_ex(this_ptr, (char*)uri, ctx, 1);
|
load_wsdl_ex(this_ptr, (char*)uri, ctx, 1);
|
||||||
xmlFree(uri);
|
xmlFree(uri);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue