Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4b0e5d6

Browse files
committed
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. This has been originally applied as 65c5864 without a backpatch, and this has come up as well when working on 400928b. Per request from Tom Lane, for new buildfarm member indri that is able to see deprecation warnings with xmlSubstituteEntitiesDefault() in 16 and older stable branches. Author: Dmitry Koval Discussion: https://postgr.es/m/18274-98d16bc03520665f@postgresql.org Discussion: https://postgr.es/m/1012981.1713222862@sss.pgh.pa.us Bakpatch-through: 12
1 parent e097086 commit 4b0e5d6

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

contrib/xml2/xpath.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ pgxml_parser_init(PgXmlStrictness strictness)
7474
/* Initialize libxml */
7575
xmlInitParser();
7676

77-
xmlSubstituteEntitiesDefault(1);
78-
7977
return xmlerrcxt;
8078
}
8179

@@ -104,7 +102,8 @@ xml_is_well_formed(PG_FUNCTION_ARGS)
104102

105103
PG_TRY();
106104
{
107-
doctree = xmlParseMemory((char *) VARDATA_ANY(t), docsize);
105+
doctree = xmlReadMemory((char *) VARDATA_ANY(t), docsize,
106+
NULL, NULL, XML_PARSE_NOENT);
108107

109108
result = (doctree != NULL);
110109

@@ -424,8 +423,9 @@ pgxml_xpath(text *document, xmlChar *xpath, xpath_workspace *workspace)
424423

425424
PG_TRY();
426425
{
427-
workspace->doctree = xmlParseMemory((char *) VARDATA_ANY(document),
428-
docsize);
426+
workspace->doctree = xmlReadMemory((char *) VARDATA_ANY(document),
427+
docsize, NULL, NULL,
428+
XML_PARSE_NOENT);
429429
if (workspace->doctree != NULL)
430430
{
431431
workspace->ctxt = xmlXPathNewContext(workspace->doctree);
@@ -718,7 +718,9 @@ xpath_table(PG_FUNCTION_ARGS)
718718

719719
/* Parse the document */
720720
if (xmldoc)
721-
doctree = xmlParseMemory(xmldoc, strlen(xmldoc));
721+
doctree = xmlReadMemory(xmldoc, strlen(xmldoc),
722+
NULL, NULL,
723+
XML_PARSE_NOENT);
722724
else /* treat NULL as not well-formed */
723725
doctree = NULL;
724726

contrib/xml2/xslt_proc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,18 @@ xslt_process(PG_FUNCTION_ARGS)
8585
bool xslt_sec_prefs_error;
8686

8787
/* Parse document */
88-
doctree = xmlParseMemory((char *) VARDATA_ANY(doct),
89-
VARSIZE_ANY_EXHDR(doct));
88+
doctree = xmlReadMemory((char *) VARDATA_ANY(doct),
89+
VARSIZE_ANY_EXHDR(doct), NULL, NULL,
90+
XML_PARSE_NOENT);
9091

9192
if (doctree == NULL)
9293
xml_ereport(xmlerrcxt, ERROR, ERRCODE_EXTERNAL_ROUTINE_EXCEPTION,
9394
"error parsing XML document");
9495

9596
/* Same for stylesheet */
96-
ssdoc = xmlParseMemory((char *) VARDATA_ANY(ssheet),
97-
VARSIZE_ANY_EXHDR(ssheet));
97+
ssdoc = xmlReadMemory((char *) VARDATA_ANY(ssheet),
98+
VARSIZE_ANY_EXHDR(ssheet), NULL, NULL,
99+
XML_PARSE_NOENT);
98100

99101
if (ssdoc == NULL)
100102
xml_ereport(xmlerrcxt, ERROR, ERRCODE_EXTERNAL_ROUTINE_EXCEPTION,

0 commit comments

Comments
 (0)