1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 20:25:14 +03:00
Commit Graph

89 Commits

Author SHA1 Message Date
Nick Wellnhofer
f307237e14 schemas: Use private copy of global NaN and Inf
Simplify symbol availability logic.
2024-06-16 18:47:12 +02:00
Nick Wellnhofer
669bd34993 xpointer: Remove support for XPointer locations
The latest spec for what it essentially an XPath extension seems to be
this working draft from 2002:

    https://www.w3.org/TR/xptr-xpointer/

The xpointer() scheme is listed as "being reviewed" in the XPointer
registry since at least 2006. libxml2 seems to be the only modern
software that tries to implement this spec, but the code has many bugs
and quality issues.

If you configure --with-legacy, old symbols are retained for ABI
compatibility.
2024-06-12 18:20:01 +02:00
Nick Wellnhofer
954b898494 xpath: Improve error handling
Introduce xmlXPathSetErrorHandler allowing to set a structured error
handler for an XPath context.

Remove arguments from memory error handlers.

Use xmlRaiseMemoryError.

Remove TODO, STRANGE and CHECK_CTXT macros.

Remove remaining uses of xmlGenericError.
2023-12-21 02:46:27 +01:00
Nick Wellnhofer
fa993130f9 xpath: Remove remaining references to valueFrame
Fixes #529.
2023-04-30 13:18:17 +02:00
Nick Wellnhofer
483793940c malloc-fail: Stop using XPath stack frames
There's too much code which assumes that if ctxt->value is non-null,
a value can be successfully popped off the stack. This assumption can
break with stack frames when malloc fails.

Instead of trying to fix all call sites, remove the stack frame logic.
It only offered very little protection against misbehaving extension
functions. We already check the stack size after a function call which
should be enough.

Found by OSS-Fuzz.
2023-03-13 17:11:27 +01:00
Nick Wellnhofer
ce9baf94d5 Remove XMLCALL and XMLCDECL macros from public headers 2022-12-08 02:48:27 +01:00
Nick Wellnhofer
670701075b Add configuration flag for XPointer locations support
Add a new configuration flag that controls whether the outdated support
for XPointer locations (ranges and points) is enabled.

    --with-xptr-locs          # Autotools
    LIBXML2_WITH_XPTR_LOCS    # CMake

The latest spec for what it essentially an XPath extension seems to be
this working draft from 2002:

    https://www.w3.org/TR/xptr-xpointer/

The xpointer() scheme is listed as "being reviewed" in the XPointer
registry since at least 2006. libxml2 seems to be the only modern
software that tries to implement this spec, but the code has many bugs
and quality issues.

The flag defaults to "off" and support for this extensions has to be
requested explicitly. The relevant API functions are deprecated.
2022-04-21 02:41:58 +02:00
Nick Wellnhofer
40483d0ce2 Deprecate module init and cleanup functions
These functions shouldn't be part of the public API. Most init
functions are only thread-safe when called from xmlInitParser. Global
variables should only be cleaned up by calling xmlCleanupParser.
2022-03-06 15:59:43 +01:00
Nick Wellnhofer
1fe385304f Remove temporary members from struct _xmlXPathContext
These values are hardcoded now and the struct members, while public,
were recently introduced and never part of an official release.
2020-12-16 15:27:13 +01:00
Nick Wellnhofer
20c60886e4 Fix typos
Resolves #133.
2020-03-08 17:41:53 +01:00
Jared Yanovich
2a350ee9b4 Large batch of typo fixes
Closes #109.
2019-09-30 18:04:38 +02:00
Nick Wellnhofer
2d97a97aa5 Optional recursion limit when parsing XPath expressions
Useful to avoid call stack overflows when fuzzing. Note that parsing a
parenthesized expression currently consumes more than 10 stack frames,
so this limit should be set rather low.
2019-04-11 15:35:57 +02:00
Nick Wellnhofer
64115ed62d Optional recursion limit when evaluating XPath expressions
Useful to avoid call stack overflows when fuzzing.
2019-04-11 15:35:57 +02:00
Nick Wellnhofer
852c93a2dc Optional XPath operation limit
Optionally limit the maximum numbers of XPath operations when evaluating
an expression. Useful to avoid timeouts when fuzzing. The following
operations count towards the limit:

- XPath operations
- Location step iterations
- Union operations

Enabled by setting opLimit to a non-zero value. Note that it's the user's
responsibility to reset opCount. This allows to enforce the operation
limit across multiple reuses of an XPath context.
2019-04-11 15:35:57 +02:00
Alex Bligh
28876afb4e Add xmlXPathSetContextNode and xmlXPathNodeEval
This patch adds xmlXPathSetContextNode and xmlXPathNodeEval,
which make it easier to evaluation XPath expressions with a
context node other than the document root without poking about
inside the internals of the context.

This patch is compile-tested only, and is my first libxml2
contribution, so please go easy.

Signed-off-by: Alex Bligh <alex@alex.org.uk>
2013-04-01 16:42:12 +08:00
Daniel Veillard
f8e3db0445 Big space and tab cleanup
Remove all space before tabs and space and tabs at end of lines.
2012-09-11 13:26:36 +08:00
Daniel Veillard
47881284ae Add a forbidden variable error number and message to XPath
Related to https://bugzilla.gnome.org/show_bug.cgi?id=680938

When the XML_XPATH_NOVAR flags is being used it means that
variables are forbidden, not that they are missing
2012-09-07 14:24:50 +08:00
Daniel Veillard
f5048b3e71 Hardening of XPath evaluation
Add a mechanism of frame for XPath evaluation when entering a function
or a scoped evaluation, also fix a potential problem in predicate
evaluation.
2011-08-19 11:07:51 +08:00
Daniel Veillard
e43579b2d4 small doc improvement for xmlXPathContext from Jack Jansen, fixes #524759
* include/libxml/xpath.h: small doc improvement for xmlXPathContext
  from Jack Jansen, fixes #524759
* doc/newapi.xsl doc/*: fixed a problem and regenerated the docs
Daniel

svn path=/trunk/; revision=3722
2008-04-03 04:56:04 +00:00
Daniel Veillard
7ef5169074 applied documentation patch from James Dennett Daniel
* include/libxml/xpath.h: applied documentation patch from James Dennett
Daniel

svn path=/trunk/; revision=3595
2007-03-21 16:47:12 +00:00
Kasimier T. Buchcik
631ea8176a Added xmlXPathCompiledEvalToBoolean() to the API and adjusted/added
* xpath.c: Added xmlXPathCompiledEvalToBoolean() to the API and
  adjusted/added xmlXPathRunEval(), xmlXPathRunStreamEval(),
  xmlXPathCompOpEvalToBoolean(), xmlXPathNodeCollectAndTest()
  to be aware of a boolean result request. The new function
  is now used to evaluate predicates.
2006-06-26 16:47:25 +00:00
Kasimier T. Buchcik
5869469f42 Changed the name of the recently added public function
* xpath.c include/libxml/xpath.h runsuite.c:
  Changed the name of the recently added public function
  xmlXPathContextSetObjectCache() to
  xmlXPathContextSetCache(); so a more generic one, in
  case we decide to cache more things than only XPath
  objects.
2006-05-31 12:37:28 +00:00
Kasimier T. Buchcik
a72484438f Added an XPath object cache. It sits on an xmlXPathContext and need to be
* xpath.c include/libxml/xpath.h: Added an XPath object cache.
  It sits on an xmlXPathContext and need to be explicitely
  activated (or deactivated again) with
  xmlXPathContextSetObjectCache(). The cache consists of 5
  lists for node-set, string, number, boolean and misc XPath
  objects. Internally the xpath.c module will use object-
  deposition and -acquisition functions which will try to reuse
  as many XPath objects as possible, and fallback to normal
  free/create behaviour if no cache is available or if the cache
  is full.
* runsuite.c: Adjusted to deactivate the cache for XML Schema
  tests if a cache-creation is turned on by default for the whole
  library, e.g. for testing purposes of the cache. It is
  deactivated here in order to avoid confusion of the memory leak
  detection in runsuite.c.
2006-05-29 16:15:36 +00:00
Daniel Veillard
b3d1491b69 prepare for release work for #303289, fix a formatting bug for MIN_INT
* configure.in doc/* configure.in: prepare for release
* xpath.c: work for #303289, fix a formatting bug for MIN_INT
Daniel
2005-09-04 20:47:39 +00:00
Daniel Veillard
ed6c54971f changed xmlPatterncompile signature to pass an int and not an enum since
* pattern.c include/libxml/pattern.h: changed xmlPatterncompile
  signature to pass an int and not an enum since it can generate
  ABI compat troubles.
* include/libxml/schematron.h schematron.c: adding the new
  schematron code, work in progress lots to be left and needing
  testing
* include/libxml/xmlversion.h.in include/libxml/xmlwin32version.h.in
  Makefile.am configure.in: integration of schematron into the
  build
* xpath.c include/libxml/xpath.h: adding flags to control compilation
  options right now just XML_XPATH_CHECKNS.
Daniel
2005-07-23 15:00:22 +00:00
William M. Brack
21e4ef20f6 Re-examined the problems of configuring a "minimal" library.
Synchronized the header files with the library code in order
to assure that all the various conditionals (LIBXML_xxxx_ENABLED)
were the same in both.  Modified the API database content to more
accurately reflect the conditionals.  Enhanced the generation
of that database.  Although there was no substantial change to
any of the library code's logic, a large number of files were
modified to achieve the above, and the configuration script
was enhanced to do some automatic enabling of features (e.g.
--with-xinclude forces --with-xpath).  Additionally, all the format
errors discovered by apibuild.py were corrected.
* configure.in: enhanced cross-checking of options
* doc/apibuild.py, doc/elfgcchack.xsl, doc/libxml2-refs.xml,
  doc/libxml2-api.xml, gentest.py: changed the usage of the
  <cond> element in module descriptions
* elfgcchack.h, testapi.c: regenerated with proper conditionals
* HTMLparser.c, SAX.c, globals.c, tree.c, xmlschemas.c, xpath.c,
  testSAX.c: cleaned up conditionals
* include/libxml/[SAX.h, SAX2.h, debugXML.h, encoding.h, entities.h,
  hash.h, parser.h, parserInternals.h, schemasInternals.h, tree.h,
  valid.h, xlink.h, xmlIO.h, xmlautomata.h, xmlreader.h, xpath.h]:
  synchronized the conditionals with the corresponding module code
* doc/examples/tree2.c, doc/examples/xpath1.c, doc/examples/xpath2.c:
  added additional conditions required for compilation
* doc/*.html, doc/html/*.html: rebuilt the docs
2005-01-02 09:53:13 +00:00
Daniel Veillard
57b2516af5 augmented type autogeneration for enums removed direct error reporting.
* gentest.py testapi.c: augmented type autogeneration for enums
* xpath.c include/libxml/xpath.h: removed direct error reporting.
Daniel
2004-11-06 14:50:18 +00:00
Daniel Veillard
6ebf3c4c1a trying to remove some warning when compiling on Fedora Core 3 and 64bits
* xmllint.c xpath.c include/libxml/xpath.h
  include/libxml/xpathInternals.h python/libxml.c
  python/libxml_wrap.h: trying to remove some warning when compiling
  on Fedora Core 3 and 64bits
Daniel
2004-08-22 13:11:39 +00:00
Daniel Veillard
a2351322c8 hack based on Arjan van de Ven suggestion to reduce ELF footprint and
* elfgcchack.h doc/elfgcchack.xsl libxml.h: hack based on Arjan van de
  Ven suggestion to reduce ELF footprint and generated code. Based on
  aliasing of libraries function to generate direct call instead of
  indirect ones
* doc/libxml2-api.xml doc/Makefile.am doc/apibuild.py: added automatic
  generation of elfgcchack.h based on the API description, extended
  the API description to show the conditionals configuration flags
  required for symbols.
* nanohttp.c parser.c xmlsave.c include/libxml/*.h: lot of cleanup
* doc/*: regenerated the docs.
Daniel
2004-06-27 12:08:10 +00:00
Daniel Veillard
4773df2a58 added io1.c an example ox xmlIO usage and io1.res test result, fixed a
* doc/examples/*: added io1.c an example ox xmlIO usage and io1.res
  test result, fixed a awful lot of memory leaks showing up in
  testWriter.c, changed the examples and the Makefiles to test
  memory leaks.
* xmlwriter.c: fixed a memory leak
* Makefile.am: run the doc/examples regression tests as part of
  make tests
* xpath.c include/libxml/xpath.h: added xmlXPathCtxtCompile() to
  compile an XPath expression within a context, currently the goal
  is to be able to reuse the XSLT stylesheet dictionnary, but this
  opens the door to others possible optimizations.
* dict.c include/libxml/dict.h: added xmlDictCreateSub() which allows
  to build a new dictionnary based on another read-only dictionnary.
  This is needed for XSLT to keep the stylesheet dictionnary read-only
  while being able to reuse the strings for the transformation
  dictionnary.
* xinclude.c: fixed a dictionnar reference counting problem occuring
  when document parsing failed.
* testSAX.c: adding option --repeat for timing 100times the parsing
* doc/* : rebuilt all the docs
Daniel
2004-01-23 13:15:13 +00:00
Daniel Veillard
be5869729a modified the file header to add more informations, painful... updated to
* include/libxml/*.h include/libxml/*.h.in: modified the file
  header to add more informations, painful...
* genChRanges.py genUnicode.py: updated to generate said changes
  in headers
* doc/apibuild.py: extract headers, add them to libxml2-api.xml
* *.html *.xsl *.xml: updated the stylesheets to flag geprecated
  APIs modules. Updated the stylesheets, some cleanups, regenerated
* doc/html/*.html: regenerated added back book1 and libxml-lib.html
Daniel
2003-11-18 20:56:51 +00:00
Daniel Veillard
d96f6d3429 cleaning up XPath error reporting that time. applied the two patches for
* error.c include/libxml/xmlerror.h include/libxml/xpath.h
  include/libxml/xpathInternals.h xpath.c: cleaning up XPath
  error reporting that time.
* threads.c: applied the two patches for TLS threads
  on Windows from Jesse Pelton
* parser.c: tiny safety patch for xmlStrPrintf() make sure the
  return is always zero terminated. Should also help detecting
  passing wrong buffer size easilly.
* result/VC/* result/valid/rss.xml.err result/valid/xlink.xml.err:
  updated the results to follow the errors string generated by
  last commit.
Daniel
2003-10-07 21:25:12 +00:00
Igor Zlatkovic
aa3cfbd080 realigned parameters after taint 2003-08-27 08:59:58 +00:00
Igor Zlatkovic
76874e4516 Exportability taint of the headers 2003-08-25 09:05:12 +00:00
Daniel Veillard
e4fa293265 first part of the fix to performance bug #108905, adds
* xpath.c include/libxml/xpath.h: first part of the fix to
  performance bug #108905, adds xmlXPathOrderDocElems() providing
  document order for nodes.
* python/libxml.c: Python may require TRIO as Albert Chin pointed out
Daniel
2003-03-26 00:38:10 +00:00
Daniel Veillard
61f261749f Heiko W. Rupp fixed a lot of comments to generate better API descriptions
* include/libxml/*.h: Heiko W. Rupp fixed a lot of comments
  to generate better API descriptions etc...
Daniel
2002-03-12 18:46:39 +00:00
Daniel Veillard
044fc6b747 fixing #61290 "namespace nodes have no parent" long standing divergence
* xpath.c: fixing #61290 "namespace nodes have no parent"
  long standing divergence from the XPath REC. NodeSets
  simply hold a copy of namespace nodes and those node ->next
  points to the parent (which may not be the node carrying the
  definition).
* include/libxml/xpath.h: flagged but didn't added a possible
  speedup
* DOCBparser.c HTMLparser.c: removed some warnings from push
  parser due to new state being added.
* tree.c: new fix from Boris Erdmann
* configure.in c14n.c include/libxml/c14n.h testC14N.c: added
  the XML Canonalization support from Aleksey Sanin
Daniel
2002-03-04 17:09:44 +00:00
Daniel Veillard
9d06d300a5 Build a new version hopefully near complete and fully documented of the
* doc/libxml2-api.xml doc/parsedecl.py: Build a new version
  hopefully near complete and fully documented of the API in XML
* HTMLtree.c SAX.c debugXML.c error.c globals.c parser.c tree.c
 xmlIO.c xmlmemory.c include/libxml/catalog.h include/libxml/hash.h
 include/libxml/list.h include/libxml/parser.h include/libxml/tree.h
 include/libxml/parserInternals.h include/libxml/valid.hi
 include/libxml/xmlIO.h include/libxml/xmlerror.hi
 include/libxml/xmlmemory.h include/libxml/xmlversion.h.ini
 include/libxml/xpath.h include/libxml/xpathInternals.h:
  Cleaned up the doc comments a lot in the process, the interface
  coverage is now 100%
Daniel
2002-01-22 18:15:52 +00:00
Daniel Veillard
cbaf399537 applied 42 documentation patches from Charlie Bozeman. Regenerated the
* *.c include/libxml/*.h doc/html/*: applied 42 documentation
  patches from Charlie Bozeman. Regenerated the HTML docs.
Daniel
2001-12-31 16:16:02 +00:00
Daniel Veillard
b06c61455f hum, restrict the integer usage gcc bug workaround to only gcc compilers
* xpath.c: hum, restrict the integer usage gcc bug workaround
  to only gcc compilers so that other architecture don't get
  penalized by this limitation.
* include/libxml/xpath.h: small typo fix from Heiko W. Rupp
Daniel
2001-08-27 14:26:30 +00:00
Daniel Veillard
cda969218b more work on the XML catalog support. small cleanup seems using list as a
* Makefile.am catalog.c xmlcatalog.c include/libxml/catalog.h:
  more work on the XML catalog support.
* parser.c include/libxml/parser.h: small cleanup seems using
  list as a public parameter name can give portability troubles
* trionan.c trionan.h xpath.c include/libxml/trionan.h
  include/libxml/xpath.h include/libxml/Makefile.am: removed
  trionan from the libxml API, added xmlXPathIsInf and xmlXPathIsNaN
  wrappers
Daniel
2001-08-21 10:56:31 +00:00
Daniel Veillard
7d7e37919f fixed a serious memory problen when walking the namespace axis showing up
* xpath.c include/libxml/xpath.h: fixed a serious memory problen
  when walking the namespace axis showing up in
  libxst/tests/general/bug-12
* xmlmemory.c: added the possibility to trace a given block
  defined by its address
Daniel
2001-07-30 13:42:13 +00:00
Thomas Broyer
ba4ad3263b added a function lookup framework
* xpath.c include/libxml/xpath{,Internals}.h: added a function
	  lookup framework
2001-07-26 16:55:21 +00:00
Daniel Veillard
5e2dace1ca Cleanup, cleanup .. removed libxml softlink for good cleanup to get 100%
Cleanup, cleanup ..
* configure.in Makefile.am: removed libxml softlink for good
* include/libxml/*.h *.c doc/Makefile.am: cleanup to get
  100% coverage by gtk-doc
Daniel
2001-07-18 19:30:27 +00:00
Thomas Broyer
f06a3d8b53 added a more convenient extension API for value and context managing Now
* include/libxml/xpath{,Internals}.h xpath.c: added a more
	  convenient extension API for value and context managing
	  Now handles external objects through xmlXPathPopExternal,
	  xmlXPathWrapExternal and xmlXPathReturnExternal.
	  Added functions for sets operations (intersection, etc.)
2001-07-16 04:52:57 +00:00
Thomas Broyer
496be68388 exported xmlXPath{NAN,PINF,NINF} fixed xmlXPathNodeSetItem when passing
* include/libxml/xpath.h: exported xmlXPath{NAN,PINF,NINF}
	  fixed xmlXPathNodeSetItem when passing index=0
2001-07-15 22:59:18 +00:00
Daniel Veillard
5168dbfe53 small cleanup update Daniel
* include/libxml/xpath.h: small cleanup
* doc/xml.html: update
Daniel
2001-07-07 00:18:23 +00:00
Daniel Veillard
f06307e2c1 - xpath.c include/libxml/xpath.h include/libxml/xpathInternals.h:
lot of optimization work, results in significant improvements
  when handling really complex XPath queries. Add a small optimizer
  for unions, improve [n] and [last()], avoid some costly ops.
Daniel
2001-07-03 10:35:50 +00:00
Daniel Veillard
c5d64345cf Summer's cleanup, a really big one:
* AUTHORS: added William and Bjorn
* include/libxml/*.h *.c README doc/*.html etc.: changed old email to
  daniel@veillard.com hopefully I won't have to do this again
* doc/Makefile.am doc/html/*.html: cleanup makefile, checked that
  docs can be rebuilt cleanly now
* include/libxml/xml*version.h*: removed include/libxml/xmlversion.h
  from CVs it's generated, added include/libxml/xmlwin32version.h
  also generated but which should change far less frequently.
* catalog.c nanoftp.c: made sure to include libxml.h not
  libxml/xmlversion.h directly
* include/libxml/*.h: include xmlwin32version.h instead of xmlversion.h
  when compiling on WIN32 and MSC
Daniel
2001-06-24 12:13:24 +00:00
Daniel Veillard
42596ad20c - tree.c: fixed a gross mistake in base computation, xml:base is
not completely correct yet (need cascade).
- xpath.[ch]: added the few things needed to find a function name
  and URI from the XPath context when it is called.
Daniel
2001-05-22 16:57:14 +00:00