This is an automated email from the ASF dual-hosted git repository.

leborchuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit aa9d83765aa54b4ea1142995131019222383f5b2
Author: Michael Paquier <[email protected]>
AuthorDate: Wed Jan 17 08:53:16 2024 +0900

    xml2: Replace deprecated routines with recommended ones
    
    Some functions are used in the tree and are currently marked as
    deprecated by upstream.  This commit refreshes the code to use the
    recommended functions, leading to the following changes:
    - xmlSubstituteEntitiesDefault() is gone, and needs to be replaced with
    XML_PARSE_NOENT for the paths doing the parsing.
    - xmlParseMemory() -> xmlReadMemory().
    
    These functions, as well as more functions setting global states, have
    been officially marked as deprecated by upstream in August 2022.  Their
    replacements exist since the 2001-ish area, as far as I have checked,
    so that should be safe.
    
    Author: Dmitry Koval
    Discussion: https://postgr.es/m/[email protected]
---
 contrib/xml2/xpath.c     | 10 ++++++----
 contrib/xml2/xslt_proc.c | 10 ++++++----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c
index f44caf00200..0555294f234 100644
--- a/contrib/xml2/xpath.c
+++ b/contrib/xml2/xpath.c
@@ -74,7 +74,6 @@ pgxml_parser_init(PgXmlStrictness strictness)
        /* Initialize libxml */
        xmlInitParser();
 
-       xmlSubstituteEntitiesDefault(1);
 
        return xmlerrcxt;
 }
@@ -424,8 +423,9 @@ pgxml_xpath(text *document, xmlChar *xpath, xpath_workspace 
*workspace)
 
        PG_TRY();
        {
-               workspace->doctree = xmlParseMemory((char *) 
VARDATA_ANY(document),
-                                                                               
        docsize);
+               workspace->doctree = xmlReadMemory((char *) 
VARDATA_ANY(document),
+                                                                               
   docsize, NULL, NULL,
+                                                                               
   XML_PARSE_NOENT);
                if (workspace->doctree != NULL)
                {
                        workspace->ctxt = 
xmlXPathNewContext(workspace->doctree);
@@ -718,7 +718,9 @@ xpath_table(PG_FUNCTION_ARGS)
 
                        /* Parse the document */
                        if (xmldoc)
-                               doctree = xmlParseMemory(xmldoc, 
strlen(xmldoc));
+                               doctree = xmlReadMemory(xmldoc, strlen(xmldoc),
+                                                                               
NULL, NULL,
+                                                                               
XML_PARSE_NOENT);
                        else                            /* treat NULL as not 
well-formed */
                                doctree = NULL;
 
diff --git a/contrib/xml2/xslt_proc.c b/contrib/xml2/xslt_proc.c
index 2189bca86ff..f30a3a42c03 100644
--- a/contrib/xml2/xslt_proc.c
+++ b/contrib/xml2/xslt_proc.c
@@ -85,16 +85,18 @@ xslt_process(PG_FUNCTION_ARGS)
                bool            xslt_sec_prefs_error;
 
                /* Parse document */
-               doctree = xmlParseMemory((char *) VARDATA_ANY(doct),
-                                                                
VARSIZE_ANY_EXHDR(doct));
+               doctree = xmlReadMemory((char *) VARDATA_ANY(doct),
+                                                               
VARSIZE_ANY_EXHDR(doct), NULL, NULL,
+                                                               
XML_PARSE_NOENT);
 
                if (doctree == NULL)
                        xml_ereport(xmlerrcxt, ERROR, 
ERRCODE_EXTERNAL_ROUTINE_EXCEPTION,
                                                "error parsing XML document");
 
                /* Same for stylesheet */
-               ssdoc = xmlParseMemory((char *) VARDATA_ANY(ssheet),
-                                                          
VARSIZE_ANY_EXHDR(ssheet));
+               ssdoc = xmlReadMemory((char *) VARDATA_ANY(ssheet),
+                                                         
VARSIZE_ANY_EXHDR(ssheet), NULL, NULL,
+                                                         XML_PARSE_NOENT);
 
                if (ssdoc == NULL)
                        xml_ereport(xmlerrcxt, ERROR, 
ERRCODE_EXTERNAL_ROUTINE_EXCEPTION,


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to