1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-25 10:50:08 +03:00

parser: Deprecate global parser options

Note that setting global options has no effect anyway when using any of
the modern parser API functions which take an option argument like
xmlReadMemory or when using xmlCtxtUseOptions.

Global options only have an effect when using old API functions
xmlParse* or xmlSAXParse* or when using an xmlParserCtxt without calling
xmlCtxtUseOptions.

Unfortunately, many downstream projects still modify global parser
options often without realizing that it has no effect. If necessary,
switch to the modern API. Then you can safely remove all code that
changes global options.

Here's a list of deprecated functions and global variables together with
the corresponding parser options.

- xmlSubstituteEntitiesDefault, xmlSubstituteEntitiesDefaultValue
  Parser option XML_PARSE_NOENT

- xmlKeepBlanksDefault, xmlKeepBlanksDefaultValue
  Inverse of parser option XML_PARSE_NOBLANKS

- xmlPedanticParserDefault, xmlPedanticParserDefaultValue
  Parser option XML_PARSE_PEDANTIC

- xmlLineNumbersDefault, xmlLineNumbersDefaultValue
  Always enabled by new API

- xmlDoValidityCheckingDefaultValue
  Parser option XML_PARSE_DTDVALID

- xmlGetWarningsDefaultValue
  Inverse of parser option XML_PARSE_NOWARNING

- xmlLoadExtDtdDefaultValue
  Parser options XML_PARSE_DTDLOAD and XML_PARSE_DTDATTR
This commit is contained in:
Nick Wellnhofer 2023-09-20 13:56:16 +02:00
parent 209516acbf
commit db8b9722cb
3 changed files with 43 additions and 31 deletions

View File

@ -40,31 +40,31 @@ XMLPUBFUN void
xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler);
XMLPUBFUN void
xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler);
XML_DEPRECATED XMLPUBFUN xmlBufferAllocationScheme
xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v);
XML_DEPRECATED XMLPUBFUN int
xmlThrDefDefaultBufferSize(int v);
XMLPUBFUN int
xmlThrDefDoValidityCheckingDefaultValue(int v);
XMLPUBFUN int
xmlThrDefGetWarningsDefaultValue(int v);
XMLPUBFUN int
xmlThrDefIndentTreeOutput(int v);
XMLPUBFUN const char *
xmlThrDefTreeIndentString(const char * v);
XMLPUBFUN int
xmlThrDefSaveNoEmptyTags(int v);
XML_DEPRECATED XMLPUBFUN xmlBufferAllocationScheme
xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v);
XML_DEPRECATED XMLPUBFUN int
xmlThrDefDefaultBufferSize(int v);
XML_DEPRECATED XMLPUBFUN int
xmlThrDefDoValidityCheckingDefaultValue(int v);
XML_DEPRECATED XMLPUBFUN int
xmlThrDefGetWarningsDefaultValue(int v);
XML_DEPRECATED XMLPUBFUN int
xmlThrDefKeepBlanksDefaultValue(int v);
XML_DEPRECATED XMLPUBFUN int
xmlThrDefLineNumbersDefaultValue(int v);
XMLPUBFUN int
XML_DEPRECATED XMLPUBFUN int
xmlThrDefLoadExtDtdDefaultValue(int v);
XMLPUBFUN int
XML_DEPRECATED XMLPUBFUN int
xmlThrDefParserDebugEntities(int v);
XML_DEPRECATED XMLPUBFUN int
xmlThrDefPedanticParserDefaultValue(int v);
XMLPUBFUN int
xmlThrDefSaveNoEmptyTags(int v);
XMLPUBFUN int
XML_DEPRECATED XMLPUBFUN int
xmlThrDefSubstituteEntitiesDefaultValue(int v);
XMLPUBFUN xmlRegisterNodeFunc
xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func);
@ -91,27 +91,29 @@ xmlDllMain(void *hinstDLL, unsigned long fdwReason,
#define XML_GLOBALS_CORE \
XML_OP(xmlLastError, xmlError, XML_EMPTY) \
XML_OP(xmlGenericError, xmlGenericErrorFunc, XML_EMPTY) \
XML_OP(xmlGenericErrorContext, void *, XML_EMPTY) \
XML_OP(xmlStructuredError, xmlStructuredErrorFunc, XML_EMPTY) \
XML_OP(xmlStructuredErrorContext, void *, XML_EMPTY) \
XML_OP(xmlParserVersion, const char *, XML_EMPTY) \
/* output options */ \
XML_OP(xmlIndentTreeOutput, int, XML_EMPTY) \
XML_OP(xmlTreeIndentString, const char *, XML_EMPTY) \
XML_OP(xmlSaveNoEmptyTags, int, XML_EMPTY) \
/* deprecated */ \
XML_OP(oldXMLWDcompatibility, int, XML_DEPRECATED) \
XML_OP(xmlBufferAllocScheme, xmlBufferAllocationScheme, XML_DEPRECATED) \
XML_OP(xmlDefaultBufferSize, int, XML_DEPRECATED) \
XML_OP(xmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED) \
XML_OP(xmlDefaultSAXLocator, xmlSAXLocator, XML_DEPRECATED) \
XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_EMPTY) \
XML_OP(xmlGenericError, xmlGenericErrorFunc, XML_EMPTY) \
XML_OP(xmlStructuredError, xmlStructuredErrorFunc, XML_EMPTY) \
XML_OP(xmlGenericErrorContext, void *, XML_EMPTY) \
XML_OP(xmlStructuredErrorContext, void *, XML_EMPTY) \
XML_OP(xmlGetWarningsDefaultValue, int, XML_EMPTY) \
XML_OP(xmlIndentTreeOutput, int, XML_EMPTY) \
XML_OP(xmlTreeIndentString, const char *, XML_EMPTY) \
XML_OP(xmlKeepBlanksDefaultValue, int, XML_EMPTY) \
XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlLoadExtDtdDefaultValue, int, XML_EMPTY) \
XML_OP(xmlParserDebugEntities, int, XML_EMPTY) \
XML_OP(xmlParserVersion, const char *, XML_EMPTY) \
XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlParserDebugEntities, int, XML_DEPRECATED) \
XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlSaveNoEmptyTags, int, XML_EMPTY) \
XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_EMPTY) \
XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlRegisterNodeDefaultValue, xmlRegisterNodeFunc, XML_DEPRECATED) \
XML_OP(xmlDeregisterNodeDefaultValue, xmlDeregisterNodeFunc, \
XML_DEPRECATED) \

View File

@ -850,15 +850,15 @@ XMLPUBFUN xmlDocPtr
xmlParseMemory (const char *buffer,
int size);
#endif /* LIBXML_SAX1_ENABLED */
XMLPUBFUN int
XML_DEPRECATED XMLPUBFUN int
xmlSubstituteEntitiesDefault(int val);
XMLPUBFUN int
XML_DEPRECATED XMLPUBFUN int
xmlKeepBlanksDefault (int val);
XMLPUBFUN void
xmlStopParser (xmlParserCtxtPtr ctxt);
XMLPUBFUN int
XML_DEPRECATED XMLPUBFUN int
xmlPedanticParserDefault(int val);
XMLPUBFUN int
XML_DEPRECATED XMLPUBFUN int
xmlLineNumbersDefault (int val);
#ifdef LIBXML_SAX1_ENABLED

View File

@ -310,6 +310,8 @@ deprecated_funcs = {
'xmlInitializeDict': True,
'xmlInitializePredefinedEntities': True,
'xmlIsRef': True,
'xmlKeepBlanksDefault': True,
'xmlLineNumbersDefault': True,
'xmlNamespaceParseNCName': True,
'xmlNamespaceParseNSDef': True,
'xmlNanoFTPCleanup': True,
@ -354,6 +356,7 @@ deprecated_funcs = {
'xmlParseXMLDecl': True,
'xmlParserHandlePEReference': True,
'xmlParserHandleReference': True,
'xmlPedanticParserDefault': True,
'xmlRecoverDoc': True,
'xmlRecoverFile': True,
'xmlRecoverMemory': True,
@ -368,9 +371,16 @@ deprecated_funcs = {
'xmlSkipBlankChars': True,
'xmlStringDecodeEntities': True,
'xmlStringLenDecodeEntities': True,
'xmlSubstituteEntitiesDefault': True,
'xmlThrDefDefaultBufferSize': True,
'xmlThrDefDoValidityCheckingDefaultValue': True,
'xmlThrDefGetWarningsDefaultValue': True,
'xmlThrDefKeepBlanksDefaultValue': True,
'xmlThrDefLineNumbersDefaultValue': True,
'xmlThrDefLoadExtDtdDefaultValue': True,
'xmlThrDefParserDebugEntities': True,
'xmlThrDefPedanticParserDefaultValue': True,
'xmlThrDefSubstituteEntitiesDefaultValue': True,
'xmlXPathInit': True,
'xmlXPtrEvalRangePredicate': True,
'xmlXPtrNewCollapsedRange': True,