1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

Deprecate IDREF-related functions in valid.h

These functions are only needed internally for validation.

xmlGetRefs is inherently unsafe because the ref table isn't updated
if attributes are removed (unlike the ids table).

None of the Ubuntu 20.04 packages depending on libxml2 use any of these
functions (except xmlFreeRefTable in libxslt), so it seems perfectly
safe to deprecate them.

Remove xmlIsRef and xmlRemoveRef from the Python bindings.
This commit is contained in:
Nick Wellnhofer
2022-02-20 19:02:31 +01:00
parent 61de92979b
commit 004fe9de53
3 changed files with 22 additions and 0 deletions

View File

@ -283,20 +283,25 @@ XMLPUBFUN int XMLCALL
xmlAttrPtr attr); xmlAttrPtr attr);
/* IDREFs */ /* IDREFs */
XML_DEPRECATED
XMLPUBFUN xmlRefPtr XMLCALL XMLPUBFUN xmlRefPtr XMLCALL
xmlAddRef (xmlValidCtxtPtr ctxt, xmlAddRef (xmlValidCtxtPtr ctxt,
xmlDocPtr doc, xmlDocPtr doc,
const xmlChar *value, const xmlChar *value,
xmlAttrPtr attr); xmlAttrPtr attr);
XML_DEPRECATED
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlFreeRefTable (xmlRefTablePtr table); xmlFreeRefTable (xmlRefTablePtr table);
XML_DEPRECATED
XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL
xmlIsRef (xmlDocPtr doc, xmlIsRef (xmlDocPtr doc,
xmlNodePtr elem, xmlNodePtr elem,
xmlAttrPtr attr); xmlAttrPtr attr);
XML_DEPRECATED
XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL
xmlRemoveRef (xmlDocPtr doc, xmlRemoveRef (xmlDocPtr doc,
xmlAttrPtr attr); xmlAttrPtr attr);
XML_DEPRECATED
XMLPUBFUN xmlListPtr XMLCALL XMLPUBFUN xmlListPtr XMLCALL
xmlGetRefs (xmlDocPtr doc, xmlGetRefs (xmlDocPtr doc,
const xmlChar *ID); const xmlChar *ID);

View File

@ -289,7 +289,14 @@ skip_impl = (
'xmlSaveFormatFileTo', 'xmlSaveFormatFileTo',
) )
deprecated_funcs = {
'xmlIsRef': True,
'xmlRemoveRef': True,
}
def skip_function(name): def skip_function(name):
if name in deprecated_funcs:
return 1
if name[0:12] == "xmlXPathWrap": if name[0:12] == "xmlXPathWrap":
return 1 return 1
if name == "xmlFreeParserCtxt": if name == "xmlFreeParserCtxt":

10
valid.c
View File

@ -3000,6 +3000,8 @@ xmlDummyCompare(const void *data0 ATTRIBUTE_UNUSED,
* @value: the value name * @value: the value name
* @attr: the attribute holding the Ref * @attr: the attribute holding the Ref
* *
* DEPRECATED, do not use. This function will be removed from the public API.
*
* Register a new ref declaration * Register a new ref declaration
* *
* Returns NULL if not, otherwise the new xmlRefPtr * Returns NULL if not, otherwise the new xmlRefPtr
@ -3100,6 +3102,8 @@ failed:
* xmlFreeRefTable: * xmlFreeRefTable:
* @table: An ref table * @table: An ref table
* *
* DEPRECATED, do not use. This function will be removed from the public API.
*
* Deallocate the memory used by an Ref hash table. * Deallocate the memory used by an Ref hash table.
*/ */
void void
@ -3113,6 +3117,8 @@ xmlFreeRefTable(xmlRefTablePtr table) {
* @elem: the element carrying the attribute * @elem: the element carrying the attribute
* @attr: the attribute * @attr: the attribute
* *
* DEPRECATED, do not use. This function will be removed from the public API.
*
* Determine whether an attribute is of type Ref. In case we have DTD(s) * Determine whether an attribute is of type Ref. In case we have DTD(s)
* then this is simple, otherwise we use an heuristic: name Ref (upper * then this is simple, otherwise we use an heuristic: name Ref (upper
* or lowercase). * or lowercase).
@ -3155,6 +3161,8 @@ xmlIsRef(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr) {
* @doc: the document * @doc: the document
* @attr: the attribute * @attr: the attribute
* *
* DEPRECATED, do not use. This function will be removed from the public API.
*
* Remove the given attribute from the Ref table maintained internally. * Remove the given attribute from the Ref table maintained internally.
* *
* Returns -1 if the lookup failed and 0 otherwise * Returns -1 if the lookup failed and 0 otherwise
@ -3211,6 +3219,8 @@ xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) {
* @doc: pointer to the document * @doc: pointer to the document
* @ID: the ID value * @ID: the ID value
* *
* DEPRECATED, do not use. This function will be removed from the public API.
*
* Find the set of references for the supplied ID. * Find the set of references for the supplied ID.
* *
* Returns NULL if not found, otherwise node set for the ID. * Returns NULL if not found, otherwise node set for the ID.