From 0339930d78bd34d7279f37dbd33a94d97cd506ed Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 28 May 2025 23:48:31 +0200 Subject: [PATCH 1/6] Remove unused soap macros --- ext/soap/php_xml.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/ext/soap/php_xml.h b/ext/soap/php_xml.h index 8bbb8f316061e..854be614774af 100644 --- a/ext/soap/php_xml.h +++ b/ext/soap/php_xml.h @@ -41,20 +41,6 @@ xmlNodePtr get_node_with_attribute_ex(xmlNodePtr node, char *name, char *name_ns xmlNodePtr get_node_with_attribute_recursive_ex(xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns); void parse_namespace(const xmlChar *inval, const char **value, char **namespace); -#define FOREACHATTRNODE(n,c,i) FOREACHATTRNODEEX(n,c,NULL,i) -#define FOREACHATTRNODEEX(n,c,ns,i) \ - do { \ - if (n == NULL) { \ - break; \ - } \ - if (c) { \ - i = get_attribute_ex(n,c,ns); \ - } else { \ - i = n; \ - } \ - if (i != NULL) { \ - n = i; - #define FOREACHNODE(n,c,i) FOREACHNODEEX(n,c,NULL,i) #define FOREACHNODEEX(n,c,ns,i) \ do { \ From 520cf338bc61480668b973709d7df91cb924b62c Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 28 May 2025 23:49:51 +0200 Subject: [PATCH 2/6] Fix indentation --- ext/soap/php_schema.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c index e1bf37686ac1d..ac4fb60cb2c0c 100644 --- a/ext/soap/php_schema.c +++ b/ext/soap/php_schema.c @@ -1670,7 +1670,7 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr element, sdlTyp break; } parent = parent->parent; - } + } if (parent == NULL) { cur_type->form = XSD_FORM_UNQUALIFIED; } From a59b44c77d5f427d6dc81e6f805a75e4eecc03c0 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 28 May 2025 23:51:54 +0200 Subject: [PATCH 3/6] Add const qualifiers for php_xml --- ext/soap/php_xml.c | 14 +++++++------- ext/soap/php_xml.h | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c index d39688b59b5cd..10581f4192a65 100644 --- a/ext/soap/php_xml.c +++ b/ext/soap/php_xml.c @@ -203,7 +203,7 @@ xmlNsPtr node_find_ns(xmlNodePtr node) } } -int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns) +int attr_is_equal_ex(xmlAttrPtr node, const char *name, const char *ns) { if (name == NULL || ((node->name) && strcmp((char*)node->name, name) == 0)) { if (ns) { @@ -219,7 +219,7 @@ int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns) return FALSE; } -int node_is_equal_ex(xmlNodePtr node, char *name, char *ns) +int node_is_equal_ex(xmlNodePtr node, const char *name, const char *ns) { if (name == NULL || ((node->name) && strcmp((char*)node->name, name) == 0)) { if (ns) { @@ -236,7 +236,7 @@ int node_is_equal_ex(xmlNodePtr node, char *name, char *ns) } -xmlAttrPtr get_attribute_ex(xmlAttrPtr node, char *name, char *ns) +xmlAttrPtr get_attribute_ex(xmlAttrPtr node, const char *name, const char *ns) { while (node!=NULL) { if (attr_is_equal_ex(node, name, ns)) { @@ -247,7 +247,7 @@ xmlAttrPtr get_attribute_ex(xmlAttrPtr node, char *name, char *ns) return NULL; } -xmlNodePtr get_node_ex(xmlNodePtr node, char *name, char *ns) +xmlNodePtr get_node_ex(xmlNodePtr node, const char *name, const char *ns) { while (node!=NULL) { if (node_is_equal_ex(node, name, ns)) { @@ -258,7 +258,7 @@ xmlNodePtr get_node_ex(xmlNodePtr node, char *name, char *ns) return NULL; } -xmlNodePtr get_node_recurisve_ex(xmlNodePtr node, char *name, char *ns) +xmlNodePtr get_node_recurisve_ex(xmlNodePtr node, const char *name, const char *ns) { while (node != NULL) { if (node_is_equal_ex(node, name, ns)) { @@ -274,7 +274,7 @@ xmlNodePtr get_node_recurisve_ex(xmlNodePtr node, char *name, char *ns) return NULL; } -xmlNodePtr get_node_with_attribute_ex(xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns) +xmlNodePtr get_node_with_attribute_ex(xmlNodePtr node, const char *name, const char *name_ns, const char *attribute, const char *value, const char *attr_ns) { xmlAttrPtr attr; @@ -295,7 +295,7 @@ xmlNodePtr get_node_with_attribute_ex(xmlNodePtr node, char *name, char *name_ns return NULL; } -xmlNodePtr get_node_with_attribute_recursive_ex(xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns) +xmlNodePtr get_node_with_attribute_recursive_ex(xmlNodePtr node, const char *name, const char *name_ns, const char *attribute, const char *value, const char *attr_ns) { while (node != NULL) { if (node_is_equal_ex(node, name, name_ns)) { diff --git a/ext/soap/php_xml.h b/ext/soap/php_xml.h index 854be614774af..d46767e68ed04 100644 --- a/ext/soap/php_xml.h +++ b/ext/soap/php_xml.h @@ -32,13 +32,13 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t size); xmlNsPtr attr_find_ns(xmlAttrPtr node); xmlNsPtr node_find_ns(xmlNodePtr node); -int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns); -int node_is_equal_ex(xmlNodePtr node, char *name, char *ns); -xmlAttrPtr get_attribute_ex(xmlAttrPtr node,char *name, char *ns); -xmlNodePtr get_node_ex(xmlNodePtr node,char *name, char *ns); -xmlNodePtr get_node_recursive_ex(xmlNodePtr node,char *name, char *ns); -xmlNodePtr get_node_with_attribute_ex(xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns); -xmlNodePtr get_node_with_attribute_recursive_ex(xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns); +int attr_is_equal_ex(xmlAttrPtr node, const char *name, const char *ns); +int node_is_equal_ex(xmlNodePtr node, const char *name, const char *ns); +xmlAttrPtr get_attribute_ex(xmlAttrPtr node,const char *name, const char *ns); +xmlNodePtr get_node_ex(xmlNodePtr node, const char *name, const char *ns); +xmlNodePtr get_node_recursive_ex(xmlNodePtr node, const char *name, const char *ns); +xmlNodePtr get_node_with_attribute_ex(xmlNodePtr node, const char *name, const char *name_ns, const char *attribute, const char *value, const char *attr_ns); +xmlNodePtr get_node_with_attribute_recursive_ex(xmlNodePtr node, const char *name, const char *name_ns, const char *attribute, const char *value, const char *attr_ns); void parse_namespace(const xmlChar *inval, const char **value, char **namespace); #define FOREACHNODE(n,c,i) FOREACHNODEEX(n,c,NULL,i) From 9633e30f730fc94559c08f24840e7ad8568f0b54 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 28 May 2025 23:52:12 +0200 Subject: [PATCH 4/6] Add FIXME --- ext/soap/php_xml.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c index 10581f4192a65..ca946c1ee0895 100644 --- a/ext/soap/php_xml.c +++ b/ext/soap/php_xml.c @@ -183,6 +183,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size) return ret; } +/* FIXME: this is wrong, attributes don't inherit the namespace of the node they're in! */ xmlNsPtr attr_find_ns(xmlAttrPtr node) { if (node->ns) { From 94abe53d2ccbe14500f98dcad60ccbd9ebe46bfb Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 28 May 2025 23:53:06 +0200 Subject: [PATCH 5/6] Remove uncommented init/cleanup code This is irrelevant and is done by ext/libxml. --- ext/soap/php_xml.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c index ca946c1ee0895..ca21cf42e5e44 100644 --- a/ext/soap/php_xml.c +++ b/ext/soap/php_xml.c @@ -80,10 +80,6 @@ xmlDocPtr soap_xmlParseFile(const char *filename) xmlDocPtr ret; bool old_allow_url_fopen; -/* - xmlInitParser(); -*/ - old_allow_url_fopen = PG(allow_url_fopen); PG(allow_url_fopen) = 1; ctxt = xmlCreateFileParserCtxt(filename); @@ -120,10 +116,6 @@ xmlDocPtr soap_xmlParseFile(const char *filename) ret = NULL; } -/* - xmlCleanupParser(); -*/ - if (ret) { cleanup_xml_node((xmlNodePtr)ret); } @@ -135,10 +127,6 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size) xmlParserCtxtPtr ctxt = NULL; xmlDocPtr ret; - -/* - xmlInitParser(); -*/ ctxt = xmlCreateMemoryParserCtxt(buf, buf_size); if (ctxt) { bool old; @@ -171,10 +159,6 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size) ret = NULL; } -/* - xmlCleanupParser(); -*/ - /* if (ret) { cleanup_xml_node((xmlNodePtr)ret); From e2f77d6de00396264c4f48d849a147a6cb16762d Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 28 May 2025 23:54:53 +0200 Subject: [PATCH 6/6] Remove unused function in soap --- ext/soap/php_xml.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c index ca21cf42e5e44..f3b8e18f7ddfe 100644 --- a/ext/soap/php_xml.c +++ b/ext/soap/php_xml.c @@ -35,7 +35,7 @@ static bool is_blank(const xmlChar* str) return true; } -/* removes all empty text, comments and other insignoficant nodes */ +/* removes all empty text, comments and other insignificant nodes */ static void cleanup_xml_node(xmlNodePtr node) { xmlNodePtr trav; @@ -243,22 +243,6 @@ xmlNodePtr get_node_ex(xmlNodePtr node, const char *name, const char *ns) return NULL; } -xmlNodePtr get_node_recurisve_ex(xmlNodePtr node, const char *name, const char *ns) -{ - while (node != NULL) { - if (node_is_equal_ex(node, name, ns)) { - return node; - } else if (node->children != NULL) { - xmlNodePtr tmp = get_node_recurisve_ex(node->children, name, ns); - if (tmp) { - return tmp; - } - } - node = node->next; - } - return NULL; -} - xmlNodePtr get_node_with_attribute_ex(xmlNodePtr node, const char *name, const char *name_ns, const char *attribute, const char *value, const char *attr_ns) { xmlAttrPtr attr;