1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-30 22:43:14 +03:00

another patch from Malcolm Tredinnick adding option not to load dtd from

* python/drv_libxml2.py: another patch from Malcolm Tredinnick
  adding option not to load dtd from the drv_libxml2.py module
  #134633
Daniel
This commit is contained in:
Daniel Veillard
2004-09-29 09:04:00 +00:00
parent c7e3cc49ba
commit bc2f2c3de4
2 changed files with 16 additions and 10 deletions

View File

@ -1,3 +1,9 @@
Wed Sep 29 11:03:10 CEST 2004 Daniel Veillard <daniel@veillard.com>
* python/drv_libxml2.py: another patch from Malcolm Tredinnick
adding option not to load dtd from the drv_libxml2.py module
#134633
Tue Sep 28 14:30:22 CEST 2004 Daniel Veillard <daniel@veillard.com> Tue Sep 28 14:30:22 CEST 2004 Daniel Veillard <daniel@veillard.com>
* acconfig.h config.h.in configure.in xmlIO.c xmlregexp.c xmlschemas.c * acconfig.h config.h.in configure.in xmlIO.c xmlregexp.c xmlschemas.c

View File

@ -38,7 +38,6 @@ __author__ = u"St
__version__ = "0.3" __version__ = "0.3"
import codecs import codecs
import sys
from types import StringType, UnicodeType from types import StringType, UnicodeType
StringTypes = (StringType,UnicodeType) StringTypes = (StringType,UnicodeType)
@ -100,6 +99,7 @@ class LibXml2Reader(xmlreader.XMLReader):
self.__ns = 0 self.__ns = 0
self.__nspfx = 0 self.__nspfx = 0
self.__validate = 0 self.__validate = 0
self.__extparams = 1
# parsing flag # parsing flag
self.__parsing = 0 self.__parsing = 0
# additional handlers # additional handlers
@ -142,10 +142,13 @@ class LibXml2Reader(xmlreader.XMLReader):
reader = input.newTextReader(source.getSystemId()) reader = input.newTextReader(source.getSystemId())
reader.SetErrorHandler(self._errorHandler,None) reader.SetErrorHandler(self._errorHandler,None)
# configure reader # configure reader
if self.__extparams:
reader.SetParserProp(libxml2.PARSER_LOADDTD,1) reader.SetParserProp(libxml2.PARSER_LOADDTD,1)
reader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1) reader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1)
reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1)
reader.SetParserProp(libxml2.PARSER_VALIDATE,self.__validate) reader.SetParserProp(libxml2.PARSER_VALIDATE,self.__validate)
else:
reader.SetParserProp(libxml2.PARSER_LOADDTD, 0)
# we reuse attribute maps (for a slight performance gain) # we reuse attribute maps (for a slight performance gain)
if self.__ns: if self.__ns:
attributesNSImpl = xmlreader.AttributesNSImpl({},{}) attributesNSImpl = xmlreader.AttributesNSImpl({},{})
@ -316,7 +319,7 @@ class LibXml2Reader(xmlreader.XMLReader):
elif name == feature_external_ges: elif name == feature_external_ges:
return 1 # TODO (does that relate to PARSER_LOADDTD)? return 1 # TODO (does that relate to PARSER_LOADDTD)?
elif name == feature_external_pes: elif name == feature_external_pes:
return 1 # TODO (does that relate to PARSER_LOADDTD)? return self.__extparams
else: else:
raise SAXNotRecognizedException("Feature '%s' not recognized" % \ raise SAXNotRecognizedException("Feature '%s' not recognized" % \
name) name)
@ -337,10 +340,7 @@ class LibXml2Reader(xmlreader.XMLReader):
raise SAXNotSupportedException("Feature '%s' not supported" % \ raise SAXNotSupportedException("Feature '%s' not supported" % \
name) name)
elif name == feature_external_pes: elif name == feature_external_pes:
if state == 0: self.__extparams = state
# TODO (does that relate to PARSER_LOADDTD)?
raise SAXNotSupportedException("Feature '%s' not supported" % \
name)
else: else:
raise SAXNotRecognizedException("Feature '%s' not recognized" % \ raise SAXNotRecognizedException("Feature '%s' not recognized" % \
name) name)