diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/Makefile.am | 4 | ||||
-rw-r--r-- | python/Makefile.in | 32 | ||||
-rwxr-xr-x | python/generator.py | 74 | ||||
-rwxr-xr-x | python/setup.py | 2 | ||||
-rw-r--r-- | python/tests/Makefile.in | 8 | ||||
-rw-r--r-- | python/tests/xpathleak.py | 14 |
6 files changed, 57 insertions, 77 deletions
diff --git a/python/Makefile.am b/python/Makefile.am index 8f148b1..3cf87e7 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -29,11 +29,11 @@ mylibs = \ python_LTLIBRARIES = libxml2mod.la -libxml2mod_la_SOURCES = libxml.c types.c +libxml2mod_la_SOURCES = $(srcdir)/libxml.c $(srcdir)/types.c nodist_libxml2mod_la_SOURCES = libxml2-py.c libxml2mod_la_LIBADD = $(mylibs) @CYGWIN_EXTRA_PYTHON_LIBADD@ @PYTHON_LIBS@ -libxml.c: libxml2-py.h # to generate before to compile +$(srcdir)/libxml.c: libxml2-py.h # to generate before to compile libxml2.py: $(srcdir)/libxml.py libxml2class.py diff --git a/python/Makefile.in b/python/Makefile.in index 4868b5e..d7a8015 100644 --- a/python/Makefile.in +++ b/python/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -40,8 +40,10 @@ DIST_COMMON = README $(am__dist_python_DATA_DIST) $(dist_docs_DATA) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/setup.py.in TODO ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/configure.in +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -73,7 +75,7 @@ am__installdirs = "$(DESTDIR)$(pythondir)" "$(DESTDIR)$(docsdir)" \ "$(DESTDIR)$(pythondir)" "$(DESTDIR)$(pythondir)" LTLIBRARIES = $(python_LTLIBRARIES) @WITH_PYTHON_TRUE@libxml2mod_la_DEPENDENCIES = $(mylibs) -am__libxml2mod_la_SOURCES_DIST = libxml.c types.c +am__libxml2mod_la_SOURCES_DIST = $(srcdir)/libxml.c $(srcdir)/types.c @WITH_PYTHON_TRUE@am_libxml2mod_la_OBJECTS = libxml.lo types.lo @WITH_PYTHON_TRUE@nodist_libxml2mod_la_OBJECTS = libxml2-py.lo libxml2mod_la_OBJECTS = $(am_libxml2mod_la_OBJECTS) \ @@ -386,7 +388,7 @@ libxml2mod_la_LDFLAGS = @CYGWIN_EXTRA_LDFLAGS@ @WIN32_EXTRA_LDFLAGS@ -module -av @WITH_PYTHON_TRUE@ $(top_builddir)/libxml2.la @WITH_PYTHON_TRUE@python_LTLIBRARIES = libxml2mod.la -@WITH_PYTHON_TRUE@libxml2mod_la_SOURCES = libxml.c types.c +@WITH_PYTHON_TRUE@libxml2mod_la_SOURCES = $(srcdir)/libxml.c $(srcdir)/types.c @WITH_PYTHON_TRUE@nodist_libxml2mod_la_SOURCES = libxml2-py.c @WITH_PYTHON_TRUE@libxml2mod_la_LIBADD = $(mylibs) @CYGWIN_EXTRA_PYTHON_LIBADD@ @PYTHON_LIBS@ @WITH_PYTHON_TRUE@python_DATA = \ @@ -505,6 +507,20 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +libxml.lo: $(srcdir)/libxml.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libxml.lo -MD -MP -MF $(DEPDIR)/libxml.Tpo -c -o libxml.lo `test -f '$(srcdir)/libxml.c' || echo '$(srcdir)/'`$(srcdir)/libxml.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libxml.Tpo $(DEPDIR)/libxml.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/libxml.c' object='libxml.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libxml.lo `test -f '$(srcdir)/libxml.c' || echo '$(srcdir)/'`$(srcdir)/libxml.c + +types.lo: $(srcdir)/types.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT types.lo -MD -MP -MF $(DEPDIR)/types.Tpo -c -o types.lo `test -f '$(srcdir)/types.c' || echo '$(srcdir)/'`$(srcdir)/types.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/types.Tpo $(DEPDIR)/types.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/types.c' object='types.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o types.lo `test -f '$(srcdir)/types.c' || echo '$(srcdir)/'`$(srcdir)/types.c + mostlyclean-libtool: -rm -f *.lo @@ -578,7 +594,7 @@ uninstall-pythonDATA: # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -603,7 +619,7 @@ $(RECURSIVE_TARGETS): fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -893,7 +909,7 @@ uninstall-am: uninstall-dist_docsDATA uninstall-dist_pythonDATA \ uninstall-pythonDATA uninstall-pythonLTLIBRARIES -@WITH_PYTHON_TRUE@libxml.c: libxml2-py.h # to generate before to compile +@WITH_PYTHON_TRUE@$(srcdir)/libxml.c: libxml2-py.h # to generate before to compile @WITH_PYTHON_TRUE@libxml2.py: $(srcdir)/libxml.py libxml2class.py @WITH_PYTHON_TRUE@ cat $(srcdir)/libxml.py libxml2class.py > $@ diff --git a/python/generator.py b/python/generator.py index 92a3440..9e1fdaa 100755 --- a/python/generator.py +++ b/python/generator.py @@ -24,77 +24,27 @@ else: # ####################################################################### import os -import xmllib -try: - import sgmlop -except ImportError: - sgmlop = None # accelerator not available +import xml.sax debug = 0 -if sgmlop: - class FastParser: - """sgmlop based XML parser. this is typically 15x faster - than SlowParser...""" - - def __init__(self, target): - - # setup callbacks - self.finish_starttag = target.start - self.finish_endtag = target.end - self.handle_data = target.data - - # activate parser - self.parser = sgmlop.XMLParser() - self.parser.register(self) - self.feed = self.parser.feed - self.entity = { - "amp": "&", "gt": ">", "lt": "<", - "apos": "'", "quot": '"' - } - - def close(self): - try: - self.parser.close() - finally: - self.parser = self.feed = None # nuke circular reference - - def handle_entityref(self, entity): - # <string> entity - try: - self.handle_data(self.entity[entity]) - except KeyError: - self.handle_data("&%s;" % entity) +def getparser(): + # Attach parser to an unmarshalling object. return both objects. + target = docParser() + parser = xml.sax.make_parser() + parser.setContentHandler(target) + return parser, target -else: - FastParser = None - - -class SlowParser(xmllib.XMLParser): - """slow but safe standard parser, based on the XML parser in - Python's standard library.""" - - def __init__(self, target): - self.unknown_starttag = target.start - self.handle_data = target.data - self.unknown_endtag = target.end - xmllib.XMLParser.__init__(self) - -def getparser(target = None): - # get the fastest available parser, and attach it to an - # unmarshalling object. return both objects. - if target is None: - target = docParser() - if FastParser: - return FastParser(target), target - return SlowParser(target), target - -class docParser: +class docParser(xml.sax.handler.ContentHandler): def __init__(self): self._methodname = None self._data = [] self.in_function = 0 + self.startElement = self.start + self.endElement = self.end + self.characters = self.data + def close(self): if debug: print "close" diff --git a/python/setup.py b/python/setup.py index f80a66c..6522a51 100755 --- a/python/setup.py +++ b/python/setup.py @@ -226,7 +226,7 @@ else: setup (name = "libxml2-python", # On *nix, the version number is created from setup.py.in # On windows, it is set by configure.js - version = "2.7.6", + version = "2.7.7", description = descr, author = "Daniel Veillard", author_email = "veillard@redhat.com", diff --git a/python/tests/Makefile.in b/python/tests/Makefile.in index 4aa2248..29b53e3 100644 --- a/python/tests/Makefile.in +++ b/python/tests/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -38,8 +38,10 @@ subdir = python/tests DIST_COMMON = $(dist_example_DATA) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/configure.in +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/python/tests/xpathleak.py b/python/tests/xpathleak.py index dcc144c..39f49e3 100644 --- a/python/tests/xpathleak.py +++ b/python/tests/xpathleak.py @@ -15,6 +15,14 @@ expect="""--> Invalid expression --> xmlXPathEval: evaluation failed --> Invalid expression --> xmlXPathEval: evaluation failed +--> Invalid expression +--> xmlXPathEval: evaluation failed +--> Invalid expression +--> xmlXPathEval: evaluation failed +--> Invalid expression +--> xmlXPathEval: evaluation failed +--> Invalid expression +--> xmlXPathEval: evaluation failed """ err="" def callback(ctx, str): @@ -27,7 +35,11 @@ libxml2.registerErrorHandler(callback, "-->") doc = libxml2.parseDoc("<fish/>") ctxt = doc.xpathNewContext() ctxt.setContextNode(doc) -for expr in (":false()","bad:()","bad(:)",":bad(:)","bad:(:)","bad:bad(:)"): +badexprs = ( + ":false()", "bad:()", "bad(:)", ":bad(:)", "bad:(:)", "bad:bad(:)", + "a:/b", "/c:/d", "//e:/f", "g://h" + ) +for expr in badexprs: try: ctxt.xpathEval(expr) except libxml2.xpathError, e: |