1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +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); xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler);
XMLPUBFUN void XMLPUBFUN void
xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler); 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 XMLPUBFUN int
xmlThrDefIndentTreeOutput(int v); xmlThrDefIndentTreeOutput(int v);
XMLPUBFUN const char * XMLPUBFUN const char *
xmlThrDefTreeIndentString(const char * v); xmlThrDefTreeIndentString(const char * v);
XMLPUBFUN int 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); xmlThrDefKeepBlanksDefaultValue(int v);
XML_DEPRECATED XMLPUBFUN int XML_DEPRECATED XMLPUBFUN int
xmlThrDefLineNumbersDefaultValue(int v); xmlThrDefLineNumbersDefaultValue(int v);
XMLPUBFUN int XML_DEPRECATED XMLPUBFUN int
xmlThrDefLoadExtDtdDefaultValue(int v); xmlThrDefLoadExtDtdDefaultValue(int v);
XMLPUBFUN int XML_DEPRECATED XMLPUBFUN int
xmlThrDefParserDebugEntities(int v); xmlThrDefParserDebugEntities(int v);
XML_DEPRECATED XMLPUBFUN int XML_DEPRECATED XMLPUBFUN int
xmlThrDefPedanticParserDefaultValue(int v); xmlThrDefPedanticParserDefaultValue(int v);
XMLPUBFUN int XML_DEPRECATED XMLPUBFUN int
xmlThrDefSaveNoEmptyTags(int v);
XMLPUBFUN int
xmlThrDefSubstituteEntitiesDefaultValue(int v); xmlThrDefSubstituteEntitiesDefaultValue(int v);
XMLPUBFUN xmlRegisterNodeFunc XMLPUBFUN xmlRegisterNodeFunc
xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func); xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func);
@ -91,27 +91,29 @@ xmlDllMain(void *hinstDLL, unsigned long fdwReason,
#define XML_GLOBALS_CORE \ #define XML_GLOBALS_CORE \
XML_OP(xmlLastError, xmlError, XML_EMPTY) \ 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(oldXMLWDcompatibility, int, XML_DEPRECATED) \
XML_OP(xmlBufferAllocScheme, xmlBufferAllocationScheme, XML_DEPRECATED) \ XML_OP(xmlBufferAllocScheme, xmlBufferAllocationScheme, XML_DEPRECATED) \
XML_OP(xmlDefaultBufferSize, int, XML_DEPRECATED) \ XML_OP(xmlDefaultBufferSize, int, XML_DEPRECATED) \
XML_OP(xmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED) \ XML_OP(xmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED) \
XML_OP(xmlDefaultSAXLocator, xmlSAXLocator, XML_DEPRECATED) \ XML_OP(xmlDefaultSAXLocator, xmlSAXLocator, XML_DEPRECATED) \
XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_EMPTY) \ XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlGenericError, xmlGenericErrorFunc, XML_EMPTY) \ XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlStructuredError, xmlStructuredErrorFunc, XML_EMPTY) \ XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \
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(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \ XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlLoadExtDtdDefaultValue, int, XML_EMPTY) \ XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlParserDebugEntities, int, XML_EMPTY) \ XML_OP(xmlParserDebugEntities, int, XML_DEPRECATED) \
XML_OP(xmlParserVersion, const char *, XML_EMPTY) \
XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \ XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlSaveNoEmptyTags, int, XML_EMPTY) \ XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_EMPTY) \
XML_OP(xmlRegisterNodeDefaultValue, xmlRegisterNodeFunc, XML_DEPRECATED) \ XML_OP(xmlRegisterNodeDefaultValue, xmlRegisterNodeFunc, XML_DEPRECATED) \
XML_OP(xmlDeregisterNodeDefaultValue, xmlDeregisterNodeFunc, \ XML_OP(xmlDeregisterNodeDefaultValue, xmlDeregisterNodeFunc, \
XML_DEPRECATED) \ XML_DEPRECATED) \

View File

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

View File

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