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

541 Commits

Author SHA1 Message Date
Nick Wellnhofer
14ed63b7d0 Limit recursion depth in xmlXPathCompOpEvalPredicate 2019-05-08 12:00:51 +02:00
Nick Wellnhofer
f75256e7db Remove unreachable code in xmlXPathCountFunction
After the initial test, the condition

    (type == XPATH_NODESET) || (type == XPATH_XSLT_TREE)

always holds true.
2019-04-23 18:04:19 +02:00
Nick Wellnhofer
949eced484 Fix null deref in previous commit 2019-04-22 16:04:26 +02:00
Nick Wellnhofer
c2f4da1a93 Improve XPath predicate and filter evaluation
Consolidate code paths evaluating XPath predicates and filters.

Don't push context node on stack when evaluating predicates. I have no
idea why this was done. It seems completely useless and trying to pop
the context node from a corrupted stack has already caused security
issues.

Filter nodesets in-place and don't create node sets with NULL gaps which
allows to simplify merging a great deal. Simply move matched nodes
backward and create a compact node set.

Merge xmlXPathCompOpEvalPositionalPredicate into
xmlXPathCompOpEvalPredicate.
2019-04-22 14:48:46 +02:00
Nick Wellnhofer
012f8e9284 Limit recursion depth in xmlXPathOptimizeExpression 2019-04-20 17:01:19 +02:00
Nick Wellnhofer
93a1d22380 Fix memory leaks in xmlXPathParseNameComplex error paths
Found by OSS-Fuzz.
2019-04-16 13:37:47 +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
5153c7bace Use break statements in xmlXPathCompOpEval
This prepares for the next commit.
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
Nick Wellnhofer
236dd6ab2e Check XPath stack after calling functions
Check that there's exactly one return value on the stack after calling
XPath functions. Otherwise, functions that corrupt the stack without
signaling an error could lead to memory errors.

Found with libFuzzer and UBSan.
2019-03-29 13:03:03 +01:00
Nick Wellnhofer
30a6533e01 Fix float casts in xmlXPathSubstringFunction
Rewrite conversion of double to int in xmlXPathSubstringFunction, adding
range checks to avoid undefined behavior. Make sure to add start and
length as floating-point numbers before converting to int. Fix a bug
when rounding negative start indices.

Remove unneeded calls to xmlXPathIs{Inf,NaN} and rely on IEEE math
instead. Avoid computing the string length. xmlUTF8Strsub works as
expected if the length of the requested substring exceeds the input.

Found with libFuzzer and UBSan.
2019-03-08 14:29:59 +01:00
Nick Wellnhofer
a436374994 Fix nullptr deref with XPath logic ops
If the XPath stack is corrupted, for example by a misbehaving extension
function, the "and" and "or" XPath operators could dereference NULL
pointers. Check that the XPath stack isn't empty and optimize the
logic operators slightly.

Closes: https://gitlab.gnome.org/GNOME/libxml2/issues/5

Also see
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901817
https://bugzilla.redhat.com/show_bug.cgi?id=1595985

This is CVE-2018-14404.

Thanks to Guy Inbar for the report.
2018-07-30 12:54:38 +02:00
Nick Wellnhofer
b7c50b8dde Remove stray character from comment
Fixes bug #795316:

https://bugzilla.gnome.org/show_bug.cgi?id=795316
2018-07-30 12:40:59 +02:00
Nick Wellnhofer
fa33bf317a Improve restoring of context size and position
Restore context size and position where it is modified, not in
seemingly random places.
2018-04-16 20:23:48 +02:00
Nick Wellnhofer
665df41dcc Simplify and harden nodeset filtering
If a nodeset to be filtered is empty, it can be returned without popping
it from the stack.

Make sure to restore the context node in all error paths and never set
it to NULL.

Save and restore the context node in RANGETO operations.
2018-04-16 19:45:37 +02:00
Nick Wellnhofer
029d0e960c Avoid unnecessary backups of the context node 2018-04-16 18:28:42 +02:00
Nick Wellnhofer
938835e763 Don't change context node in xmlXPathRoot 2018-04-16 18:28:42 +02:00
Nick Wellnhofer
e22a83b1d0 Stop using XPATH_OP_RESET
It only sets the context node to NULL which doesn't seem useful and can
even cause bugs like bug #795299:

https://bugzilla.gnome.org/show_bug.cgi?id=795299
2018-04-16 18:20:43 +02:00
Nick Wellnhofer
ebe12882ee Fix inconsistency in xmlXPathIsInf
We don't use HUGE_VAL for INFINITY after the most recent fix.
2018-04-16 18:18:11 +02:00
Nick Wellnhofer
7abec67147 NaN and Inf fixes for pre-C99 compilers
On some pre-C99 compilers, the NAN and INFINITY macros don't expand to
constant expressions.

Some MSVC versions complain about floating point division by zero in
constants.

Thanks to Fabrice Manfroi for the report.
2018-03-16 15:09:42 +01:00
Nick Wellnhofer
ddbb075b70 Fix xmlXPathIsNaN broken by recent commit 2017-11-27 14:33:26 +01:00
Nick Wellnhofer
b21895717d Fix -Wenum-compare warnings
Also fixes a serious bug in xmlXPtrNewRangeNodePoint.
2017-11-27 13:42:30 +01:00
Nick Wellnhofer
13acadbb1c Ignore function pointer cast warnings
Use GCC pragmas as these warnings are enabled by -Wpedantic and there's
no way to disable them selectively.
2017-11-14 16:01:48 +01:00
Nick Wellnhofer
8813f397f8 Simplify XPath NaN, inf and -0 handling
Use C99 macros NAN, INFINITY, isnan, isinf. If they're not available:

- Assume that (0.0 / 0.0) generates a NaN and !(x == x) tests for NaN.
- Use C89's HUGE_VAL for INFINITY.

Remove manual handling of NaN, infinity and negative zero in functions
xmlXPathValueFlipSign and xmlXPathDivValues.

Remove xmlXPathGetSign. All the tests for negative zero can be replaced
with a test for negative or positive zero.

Simplify xmlXPathRoundFunction.

Remove Trio dependency.

This should work on IEEE 754 compliant implementations even if the C99
macros aren't available, but will likely break some ancient platforms.
If problems arise, my plan is to port the relevant trionan.c solution
to xpath.c. Note that non-compliant implementations are impossible
to fully support, anyway, since XPath requires IEEE 754.
2017-11-14 15:58:40 +01:00
Nick Wellnhofer
e03f0a199a Fix hash callback signatures
Make sure that all parameters and return values of hash callback
functions exactly match the callback function type. This is required
to pass clang's Control Flow Integrity checks and to allow compilation
to asm.js with Emscripten.

Fixes bug 784861.
2017-11-09 16:42:47 +01:00
J. Peter Mugaas
d2c329a9a4 Fix -Wimplicit-fallthrough warnings
Add "falls through" comments to quench implicit-fallthrough warnings
which are enabled by -Wextra under GCC 7.
2017-10-21 13:49:31 +02:00
Nick Wellnhofer
d422b954be Fix pointer/int cast warnings on 64-bit Windows
On 64-bit Windows, `long` is 32 bits wide and can't hold a pointer.
Switch to ptrdiff_t instead which should be the same size as a pointer
on every somewhat sane platform without requiring C99 types like
intptr_t.

Fixes bug 788312.

Thanks to J. Peter Mugaas for the report and initial patch.
2017-10-09 13:47:49 +02:00
Nick Wellnhofer
5af594d8bc Fix comparison of nodesets to strings
Fix two bugs in xmlXPathNodeValHash which could lead to errors when
comparing nodesets to strings:

- Only use contents of text nodes to compute the hash for element nodes.
  Comments, PIs, and other node types don't affect the string-value and
  must be ignored.
- Reset `string` to NULL for node types other than text.

Reported by Aleksei on the mailing list:

    https://mail.gnome.org/archives/xml/2017-September/msg00016.html
2017-10-07 15:22:57 +02:00
Nick Wellnhofer
0f3b843b35 Fix XPath stack frame logic
Move the calls to xmlXPathSetFrame and xmlXPathPopFrame around in
xmlXPathCompOpEvalPositionalPredicate to make sure that the context
object on the stack is actually protected. Otherwise, memory corruption
can occur when calling sloppily coded XPath extension functions.

Fixes bug 783160.
2017-09-21 17:55:39 +02:00
Nick Wellnhofer
3157cf4e53 Report undefined XPath variable error message
Commit c851970 removed a redundant error message if XPath evaluation
failed. This uncovered a case where an undefined XPath variable error
wasn't reported correctly.

Thanks to Petr Pisar for the report.

Fixes bug 787941.
2017-09-20 16:13:29 +02:00
Nick Wellnhofer
ca8635bfc2 Fix debug dump of streaming XPath expressions
The debug function xmlXPathDebugDumpCompExpr would crash when
called with a "streaming" expression.

Fixes bug 787368.
2017-09-07 15:46:12 +02:00
Daniel Veillard
dbb828feb9 Fix missing part of comment for function xmlXPathEvalExpression() 2017-08-28 20:38:53 +02:00
Stéphane Michaut
454e397eb7 Porting libxml2 on zOS encoding of code
First set of patches for zOS
- entities.c parser.c tree.c xmlschemas.c xmlschemastypes.c xpath.c xpointer.c:
  ask conversion of code to ISO Latin 1 to avoid having the compiler assume
  EBCDIC codepoint for characters.
- xmlmodule.c: make sure we have support for modules
- xmlIO.c: zOS path names are special avoid dsome of the expectstions from
  Unix/Windows
2017-08-28 14:30:43 +02:00
Nick Wellnhofer
7482f41f61 Check for integer overflow in xmlXPathFormatNumber
Check for overflow before casting double to int.

Found with afl-fuzz and UBSan.
2017-06-01 22:00:19 +02:00
Nick Wellnhofer
f4029cd413 Check XPath exponents for overflow
Avoid undefined behavior and wrong results with huge exponents.

Found with afl-fuzz and UBSan.
2017-05-31 16:04:37 +02:00
Nick Wellnhofer
a58331a6ee Check for overflow in xmlXPathIsPositionalPredicate
Avoid undefined behavior when casting from double to int.

Found with afl-fuzz and UBSan.
2017-05-31 16:04:26 +02:00
Nick Wellnhofer
a851868a75 Parse small XPath numbers more accurately
Don't count leading zeros towards the fraction size limit. This allows
to parse numbers like

    0.0000000000000000000000000000000000000000000000000000000001

which is the only standard-conformant way to represent such numbers, as
scientific notation isn't allowed in XPath 1.0. (It is allowed in XPath
2.0 and in libxml2 as an extension, though.)

Overall accuracy is still bad, see bug 783238.
2017-05-31 15:46:29 +02:00
Nick Wellnhofer
4bebb030db Rework XPath rounding functions
Use the C library's floor and ceil functions. The old code was overly
complicated for no apparent reason and could result in undefined
behavior when handling NaNs (found with afl-fuzz and UBSan).

Fix wrong comment in xmlXPathRoundFunction. The implementation was
already following the spec and rounding half up.
2017-05-31 15:38:42 +02:00
Nick Wellnhofer
40f5852149 Fix axis traversal from attribute and namespace nodes
When traversing the "preceding" axis from an attribute node, we must
first go up to the attribute's containing element. Otherwise, text
children of other attributes could be returned. This made it possible
to hit a code path in xmlXPathNextAncestor which contained another bug:
The attribute node was initialized with the context node instead of the
current node. Normally, this code path is only hit via
xmlXPathNextAncestorOrSelf in which case the current and context node
are the same.

The combination of the two bugs could result in an infinite loop, found
with libFuzzer.

Traversing the "following" and the "preceding" axis from namespace nodes
should be handled similarly. This wasn't supported at all previously.
2017-05-31 14:57:46 +02:00
Nick Wellnhofer
a07a4e96d0 Fix spurious error message
Commit c851970 introduced a spurious error message when evaluating
XPath expressions with xmlXPathCompiledEvalToBoolean.
2017-05-27 17:07:53 +02:00
Nick Wellnhofer
aed407c14b Check for trailing characters in XPath expressions earlier
Move the check for trailing characters from xmlXPathEval to
xmlXPathEvalExpr. Otherwise, a valid portion of a syntactically invalid
expression would be evaluated before returning an error.
2017-05-27 16:04:07 +02:00
Nick Wellnhofer
c851970c6e Rework final handling of XPath results
Move cleanup of XPath stack to xmlXPathFreeParserContext. This avoids
memory leaks if valuePop fails in some error cases. Found with
libFuzzer and ASan.

Rework handling of the final XPath result object in
xmlXPathCompiledEvalInternal and xmlXPathEval to avoid useless error
messages.
2017-05-27 16:03:48 +02:00
Nick Wellnhofer
640a368c80 Make xmlXPathEvalExpression call xmlXPathEval
Both functions are supposed to do exactly the same.
2017-05-27 15:59:18 +02:00
Nick Wellnhofer
cf60dbe461 Fix memory leak in xmlXPathCompareNodeSetValue
Implement TODO block to free the arguments in error case.

Found with libFuzzer and ASan.
2017-05-27 15:59:18 +02:00
Nick Wellnhofer
9d08b34716 Fix memory leak in xmlXPathNodeSetMergeAndClear
Namespaces nodes must not be duplicated when merging.

Found with libFuzzer and ASan.
2017-05-27 15:59:18 +02:00
Nick Wellnhofer
95a9249a60 Fix memory leak in XPath filter optimizations
Namespace nodes must be freed when selecting the first or last element
of a node set.

Found with libFuzzer and ASan.
2017-05-27 15:59:05 +02:00
Nick Wellnhofer
d42a7063da Fix memory leaks in XPath error paths
Found with libFuzzer and ASan.
2017-05-27 14:58:19 +02:00
Nick Wellnhofer
229d1f93ce Avoid function/data pointer conversion in xpath.c
Fixes a `-pedantic` compiler warning.
2016-10-12 13:23:16 +02:00
Nick Wellnhofer
9ab01a277d Fix XPointer paths beginning with range-to
The old code would invoke the broken xmlXPtrRangeToFunction. range-to
isn't really a function but a special kind of location step. Remove
this function and always handle range-to in the XPath code.

The old xmlXPtrRangeToFunction could also be abused to trigger a
use-after-free error with the potential for remote code execution.

Found with afl-fuzz.

Fixes CVE-2016-5131.
2016-10-12 13:12:18 +02:00
Nick Wellnhofer
a005199330 Fix comparison with root node in xmlXPathCmpNodes
This change has already been made in xmlXPathCmpNodesExt but not in
xmlXPathCmpNodes.
2016-10-12 13:09:21 +02:00
Nick Wellnhofer
d8083bf779 Fix NULL pointer deref in XPointer range-to
- Check for errors after evaluating first operand.
- Add sanity check for empty stack.

Found with afl-fuzz.
2016-06-25 14:24:51 +02:00
David Kilzer
4472c3a5a5 Fix some format string warnings with possible format string vulnerability
For https://bugzilla.gnome.org/show_bug.cgi?id=761029

Decorate every method in libxml2 with the appropriate
LIBXML_ATTR_FORMAT(fmt,args) macro and add some cleanups
following the reports.
2016-05-23 15:01:07 +08:00
Nick Wellnhofer
6eb0894a96 Fix memory leak with XPath namespace nodes
Set hasNsNodes to 1 when adding namespace nodes via XP_TEST_HIT.
2016-05-05 17:38:27 +02:00
Nick Wellnhofer
82b73039dc Fix namespace axis traversal
When the namespace axis is traversed in "toBool" mode, the traversal
can exit early, before visiting all nodes. In this case, the XPath
context still contains a non-NULL tmpNsList.

This means that

- the check when to start a new traversal was wrong and
- the tmpNsList could be leaked.

Fixes bug #750037 and, by accident, bug #756075:

https://bugzilla.gnome.org/show_bug.cgi?id=750037
https://bugzilla.gnome.org/show_bug.cgi?id=756075
2016-05-05 15:30:00 +02:00
Nick Wellnhofer
839689a9a8 Don't recurse into OP_VALUEs in xmlXPathOptimizeExpression
The ch1 slot of OP_VALUEs contains an invalid value. Ignore it.

Fixes bug #760325:

https://bugzilla.gnome.org/show_bug.cgi?id=760325
2016-04-27 18:05:06 +02:00
Nick Wellnhofer
f39fd66ea7 Fix namespace::node() XPath expression
Make sure that xmlXPathNodeSetAddNs is called for namespace nodes when
matched with a namespace::node() step. This correctly sets the parent
of namespace nodes. Note that xmlXPathNodeSetAddNs must only be called
if working on the namespace axis. Otherwise, the context node is not
the parent of the namespace node and the standard XP_TEST_HIT macro
must be invoked. This explains the errors in the C14N tests that the
old TODO comment mentioned.
2016-04-27 11:21:35 +02:00
Nick Wellnhofer
e289390362 Fix parsing of NCNames in XPath
The NCName parser would allow any NameChar as start character. For
example, the following XPath expressions would compile:

    self::-abc
    self::0abc
    self::.abc
2016-04-23 19:12:47 +02:00
Jan Pokorný
bb654feb9a Fix typos: dictio{ nn -> n }ar{y,ies}
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2016-04-15 22:22:48 +08:00
Shlomi Fish
d5bd2a9a40 Correct a typo. 2016-04-11 09:42:23 +08:00
Nick Wellnhofer
3eaedba1b6 Fix previous change to node sort order
Commit ba58f23 broke comparison of nodes from different documents.
Thanks to Olli Pottonen for the report.
2015-07-11 14:27:34 +02:00
Nick Wellnhofer
ba58f23c60 Fix order of root nodes
Make sure root nodes are sorted before other nodes.
2015-03-08 16:44:11 +01:00
Nick Wellnhofer
f6aaabce85 Allow attributes on descendant-or-self axis
If the context node is an attribute, the attribute itself is on the
descendant-or-self axis. The principal node type of this axis is element,
so the only node test that can return the attribute is "node()". In other
words, "@attr/descendant-or-self::node()" is equivalent to "@attr".

This matches the behavior of Saxon-CE.
2015-03-08 16:25:52 +01:00
Nick Wellnhofer
07def30fa7 Restore context size and position after XPATH_OP_ARG
Fixes a bug with predicates:
https://mail.gnome.org/archives/xml/2014-March/msg00014.html
2014-03-24 13:02:06 +01:00
Jan Pokorný
75801652a2 Fix typos in {tree,xpath}.c (errror)
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2014-02-06 10:47:47 +01:00
Nick Wellnhofer
03c6723043 Handling of XPath function arguments in error case
The XPath engine tries to guarantee that every XPath function can pop
'nargs' non-NULL values off the stack. libxslt, for example, relies on
this assumption. But the check isn't thorough enough if there are errors
during the evaluation of arguments. This can lead to segfaults:

https://mail.gnome.org/archives/xslt/2013-December/msg00005.html

This commit makes the handling of function arguments more robust.

* Bail out early when evaluation of XPath function arguments fails.
* Make sure that there are 'nargs' arguments in the current call frame.
2013-12-20 17:45:04 +01:00
Gaurav
fcd4583189 Fix XPath node comparison bug
For https://bugzilla.gnome.org/show_bug.cgi?id=715143
2013-11-28 23:01:44 +08:00
Nick Wellnhofer
e8de99f90c Fix XPath expressions of the form '@ns:*'
Use namespace for match-all queries on the attribute axis.
2013-08-05 01:26:25 +02:00
Nick Wellnhofer
b4bcba23f6 Fix XPath '//' optimization with predicates
My attempt to optimize XPath expressions containing '//' caused a
regression reported in bug #695699. This commit disables the
optimization for expressions of the form '//foo[predicate]'.
2013-08-05 00:15:11 +02:00
Denis Pauk
e28c8a1ace #705267 - add additional defines checks for support "./configure --with-minimum"
https://bugzilla.gnome.org/show_bug.cgi?id=705267
2013-08-03 22:00:17 +08:00
Daniel Veillard
b9e4d5b639 Remove occasional leading space in XPath number formatting
https://bugzilla.gnome.org/show_bug.cgi?id=704528

Somehow snprintf "%*.*e" can generate a leading space, remove it
2013-07-22 13:21:31 +08: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
713434d230 Silence a clang warning
as reported by Hans Wennborg <hans@chromium.org>
2012-09-26 10:21:06 +08:00
Daniel Veillard
7651606f31 Various cleanups to avoid compiler warnings 2012-09-11 14:02:08 +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
1bd45d1309 Change the XPath code to percolate allocation errors
looping 1000 time on an error stating that a nodeset has
grown out of control is useless, make sure we percolate
error up to the various loops and break when errors occurs
2012-09-05 15:35:19 +08:00
Daniel Veillard
510e7583f4 Fix a Timsort function helper comment 2012-09-04 11:50:36 +08:00
Vojtech Fried
3e031b7dae Switching XPath node sorting to Timsort
I use libxml xpath engine on quite large (and mostly "flat") xml files.
It seems that Shellsort, that is used in xmlXPathNodeSetSort is a
performance bottleneck for my case. I have read some posts about sorting
in libxml in the libxml archive, but I agree that qsort was not the way
to go. I experimented with Timsort instead and my results were good for
me. For about 10000 nodes, my test was about 5x faster with Timsort,
for 1000 nodes about 10% faster, for small data files, the difference
was not measurable.
* timsort.h: the algorithm, kept in a separate header
* xpath.c: plug in the new algorithm in xmlXPathNodeSetSort
* Makefile.am: add the header to the EXTRA_DIST
* doc/apibuild.py: avoid indexing the new header
2012-08-24 16:52:44 +08:00
Nick Wellnhofer
622705398a Optimizing '//' in XPath expressions
When investigating the libxslt performance problem reported in bug
#657665, I found that '//' in XPath expressions can be very slow when
working on large subtrees.

One of the reasons is the seemingly quadratic time complexity of the
duplicate checks when merging result nodes. The other is a missed
optimization for expressions of the form
'descendant-or-self::node()/axis::test'. Since '//' is expanded to
'/descendant-or-self::node()/', this type of expression is quite common.
Depending on the axis of the expression following the
'descendant-or-self' step, the following replacements can be made:

from descendant-or-self::node()/child::test
to   descendant::test

from descendant-or-self::node()/descendant::test
to   descendant::test

from descendant-or-self::node()/self::test
to   descendant-or-self::test

from descendant-or-self::node()/descendant-or-self::test
to   descendant-or-self::test

'test' can be any kind of node test.

With these replacements the possibly huge result of
'descendant-or-self::node()' doesn't have to be stored temporarily, but
can be processsed in one pass. If the resulting nodeset is small, the
duplicate checks aren't a problem.

I found that there already is a function called
xmlXPathRewriteDOSExpression which performs this optimization for a very
limited set of cases. It employs a complicated iteration scheme for
rewritten expressions. AFAICS, this can be avoided by simply changing
the axis of the expression like described above.

With the attached patch against libxml2 and the files from bug #657665 I
got the following results.

Before:

$ time xsltproc/xsltproc --noout service-names-port-numbers.xsl
service-names-port-numbers.xml
real    2m56.213s
user    2m56.123s
sys     0m0.080s

After:

$ time xsltproc/xsltproc --noout service-names-port-numbers.xsl
service-names-port-numbers.xml
real    0m3.836s
user    0m3.764s
sys     0m0.060s

I also ran the libxml2 and libxslt test suites with the patch and
couldn't detect any breakage.

Nick

>From e0f5a8261760e4f257b90410be27657e984237c8 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Sun, 19 Aug 2012 18:20:22 +0200
Subject: [PATCH] Optimizations for descendant-or-self::node()

Currently, the function xmlXPathRewriteDOSExpression optimizes expressions
of type '//child'. Instead of adding a 'rewriteType' and doing a compound
traversal, the same can be achieved simply by setting the axis of the node
test from 'child' to 'descendant'.

There are also many other cases that can be optimized similarly. This
commit augments xmlXPathRewriteDOSExpression to essentially rewrite the
following subexpressions:

- descendant-or-self::node()/child:: to descendant::
- descendant-or-self::node()/descendant:: to descendant::
- descendant-or-self::node()/self:: to descendant-or-self::
- descendant-or-self::node()/descendant-or-self:: to descendant-or-self::

Since the '//' shortcut in XPath is translated to
'/descendant-or-self::node()/', this greatly speeds up expressions using
'//' on large subtrees.
2012-08-24 12:04:25 +08:00
Daniel Veillard
3e62adbe39 Adding various checks on node type though the API
Specifially checking against namespace nodes before accessing node
pointers
2012-08-09 14:24:02 +08:00
Daniel Veillard
cd852ad154 Implement some default limits in the XPath module
This adds some internal limitationson XPath expression complexity,
and limits at runtime like depth of the stack and maximum size
for nodeset.
* xpath.c: implement the above as well as the maximum Name lenght
2012-07-30 10:12:18 +08:00
Daniel Veillard
ade10f2c57 Convert XPath to xmlBuf
Easy as no buffer was exported in the APIs
2012-07-23 14:24:26 +08:00
Daniel Veillard
1d4526f6f4 Fix missing error status in XPath evaluation
Started by Chris Evans, I added a few more place where the
error should have been set in the evaluation context.
2011-10-11 16:34:34 +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
Stefan Kost
a15404034c xpath: remove unused variable
As noted by gcc, this variable is not beeing used.
2011-05-09 11:48:21 +03:00
Chris Evans
d7958b21e7 Fix some potential problems on reallocation failures
The count was incremented before the allocation
and not fixed in case of failure
* xpath.c: corrects a few instances where the available count of some
           structure is updated before we know the allocation actually
           succeeds
2011-03-23 08:13:06 +08:00
Daniel Veillard
fec31bcd45 Small fix for previous commit 2010-11-18 11:07:24 +01:00
Daniel Veillard
df83c17e5a Fix a potential freeing error in XPath 2010-11-17 14:12:14 +01:00
Daniel Veillard
0cbeb50ee0 Fix a potential memory access error
in case of a previus allocation error
2010-11-15 12:10:14 +01:00
Phil Shafer
ee32ad3c0f 629325 XPath rounding errors first cleanup
https://bugzilla.gnome.org/show_bug.cgi?id=629325
not a full solution as Vincent Lefevre pointed out but
an incremental improvement over the status-quo
2010-11-03 20:53:55 +01:00
Daniel Veillard
ea90b89414 Fix a change of semantic on XPath preceding and following axis
This was introduced in the prevous fix, while preceding-sibling and
following sibling axis are empty for attributes and namespaces,
preceding and following axis should still work based on the parent
element. However the parent element is not available for a namespace
node, so we keep the axis empty in that case.
2010-10-22 15:50:50 +02:00
Daniel Veillard
2f3523f61f Fix a leak in XPath compilation
Sometimes a not well formed XPath expression could lead to a
leak as reported by Ralf Junker <ralfjunker@gmx.de>
2010-10-15 18:30:29 +02:00
Daniel Veillard
91d19754d4 Fix the semantic of XPath axis for namespace/attribute context nodes
The processing of namespace and attributes nodes was not compliant
to the XPath-1.0 specification
2010-10-15 14:30:52 +02:00
Marius Wachtler
2ddecc2386 Fix a small bug in XPath evaluation code 2010-10-12 09:09:07 +02:00
Martin
729601f157 Fix memory leak in xmlXPathEvalExpression()
* xpath.c: plug some leaks when parsing misformed XPath expressions
* python/tests/xpathleak.py: expand the regression tests for those
2009-10-12 22:42:26 +02:00
Daniel Veillard
594e5dfb48 Chasing dead assignments reported by clang-scan
* SAX2.c dict.c error.c hash.c nanohttp.c parser.c python/libxml.c
  relaxng.c runtest.c tree.c valid.c xinclude.c xmlregexp.c xmlsave.c
  xmlschemas.c xpath.c xpointer.c: mostly removing unneded affectations,
  but this led to a few real bugs and some part not yet understood
  (relaxng/interleave)
2009-09-07 14:58:47 +02:00
Daniel Veillard
13cee4e37b Fix a bunch of scan 'dead increments' and cleanup
* HTMLparser.c c14n.c debugXML.c entities.c nanohttp.c parser.c
  testC14N.c uri.c xmlcatalog.c xmllint.c xmlregexp.c xpath.c:
  fix unused variables, or unneeded increments as well as a couple
  of space issues
* runtest.c: check for NULL before calling unlink()
2009-09-05 14:52:55 +02:00
Daniel Veillard
bccae2d210 * c14n.c debugXML.c doc/examples/io2.c parser.c schematron.c
valid.c xmlschemas.c xmlwriter.c xpath.c: use %s to printf string
  patch by Christian Persch, fixes #581612
2009-06-04 11:22:45 +02:00
Daniel Veillard
48b3eb22c2 fixes for Borland/CodeGear/Embarcadero compilers by Eric Zurcher Daniel
* include/wsockcompat.h win32/Makefile.bcb xpath.c: fixes for
  Borland/CodeGear/Embarcadero compilers by Eric Zurcher
Daniel

svn path=/trunk/; revision=3822
2009-03-25 09:51:19 +00:00
Daniel Veillard
db3ce96906 xmlXPathRegisterNs should not allow enpty prefixes daniel
* xpath.c: xmlXPathRegisterNs should not allow enpty prefixes
daniel

svn path=/trunk/; revision=3821
2009-03-25 09:43:49 +00:00
Daniel Veillard
f63085de5e port patch from Marcus Meissner to add gcc checking for printf like
* include/libxml/parser.h include/libxml/xmlwriter.h
  include/libxml/relaxng.h include/libxml/xmlversion.h.in
  include/libxml/xmlwin32version.h.in include/libxml/valid.h
  include/libxml/xmlschemas.h include/libxml/xmlerror.h:
  port patch from Marcus Meissner to add gcc checking for
  printf like functions parameters, should fix #65068
* doc/apibuild.py doc/*: modified the script accordingly
  and regenerated
* xpath.c xmlmemory.c threads.c: fix a few warnings
Daniel

svn path=/trunk/; revision=3813
2009-01-18 20:53:59 +00:00
Daniel Veillard
074f37e7eb applied a couple of patches from Martin avoiding some leaks, fixinq QName
* schematron.c xpath.c: applied a couple of patches from Martin
  avoiding some leaks, fixinq QName checks in XPath, XPath debugging
  and schematron code cleanups.
* python/tests/Makefile.am python/tests/xpathleak.py: add the
  specific regression tests, just tweak it to avoid output by default
Daniel

svn path=/trunk/; revision=3791
2008-09-01 13:38:22 +00:00
Daniel Veillard
45490aebe7 space and tabs cleanup Daniel
* xpath.c: space and tabs cleanup
Daniel

svn path=/trunk/; revision=3756
2008-07-29 09:13:19 +00:00
Daniel Veillard
f88d849a4e two patches from Alvaro Herrera to avoid problem when running out of
* xpath.c: two patches from Alvaro Herrera to avoid problem when
  running out of memory in XPath evaluations.
Daniel

svn path=/trunk/; revision=3721
2008-04-01 08:00:31 +00:00
William M. Brack
f179456d0f fixed mlXPathCompOpEvalPositionalPredicate problem with object caching
* xpath.c: fixed mlXPathCompOpEvalPositionalPredicate problem
  with object caching (bug #469410)

svn path=/trunk/; revision=3653
2007-08-23 12:58:13 +00:00
William M. Brack
31700e6306 fixed problem in previous fix to xmlXPathNodeSetSort
* xpath.c: fixed problem in previous fix to xmlXPathNodeSetSort

svn path=/trunk/; revision=3640
2007-06-13 20:33:02 +00:00
William M. Brack
97ac819cc6 fixed problem with xmlXPathNodeSetSort; fixed problem with
* xpath.c: fixed problem with xmlXPathNodeSetSort;
  fixed problem with xmlXPathNodeTrailingSorted (both bug#413451)

svn path=/trunk/; revision=3622
2007-06-06 17:19:24 +00:00
William M. Brack
d611c88a01 fixed problem with string value for PI node (bug #442275)
* xpath.c: fixed problem with string value for PI node
  (bug #442275)

svn path=/trunk/; revision=3621
2007-05-31 05:07:17 +00:00
William M. Brack
d2f682a495 fixed problem on gzip streams (bug #438045) fixed minor spot of redundant
* nanohttp.c: fixed problem on gzip streams (bug #438045)
* xpath.c: fixed minor spot of redundant code - no logic change.

svn path=/trunk/; revision=3616
2007-05-15 19:42:08 +00:00
William M. Brack
ca79788eaa enhanced the coding for xmlXPathCastNumberToString in order to produce the
* xpath.c: enhanced the coding for xmlXPathCastNumberToString
  in order to produce the required number of significant digits
  (bug #437179)

svn path=/trunk/; revision=3615
2007-05-11 14:45:53 +00:00
William M. Brack
ee0b982fe8 fixed xmlXPathCmpNodes for incorrect result on certain cases when
* xpath.c: fixed xmlXPathCmpNodes for incorrect result on certain
  cases when comparing identical nodes (bug 415567) with patch
  from Oleg Paraschenko

svn path=/trunk/; revision=3587
2007-03-07 08:15:01 +00:00
William M. Brack
0bcec06d4c Fixed memory bug with invalid function reported by Francois Delyon on
* xpath.c: Fixed memory bug with invalid function reported by Francois Delyon on mailing list

svn path=/trunk/; revision=3584
2007-02-14 02:15:19 +00:00
William M. Brack
11be2d02b0 added checks for alloc fail on calls to xmlXPathNewContext (libxslt bug
* xpath.c: added checks for alloc fail on calls to xmlXPathNewContext
  (libxslt bug #400242)

svn path=/trunk/; revision=3575
2007-01-24 19:17:19 +00:00
Daniel Veillard
fe3970e09f fixed a bug where the principal node type of an axis wasn't tested on name
* xpath.c: fixed a bug where the principal node type of an axis
  wasn't tested on name check, fixes bug #377432
daniel
2006-11-23 16:08:30 +00:00
Daniel Veillard
17970a72ca William spotted an obvious bug Daniel
* xpath.c: William spotted an obvious bug
Daniel
2006-10-26 08:55:47 +00:00
Daniel Veillard
c465ffc20c applied patch from Olaf Walkowiak which should fix #334104 Daniel
* xpath.c: applied patch from Olaf Walkowiak which should fix #334104
Daniel
2006-10-17 19:39:33 +00:00
Kasimier T. Buchcik
50128ad7cc Applied the proposed fix for the documentation of xmlXPathCastToString();
* xpath.c: Applied the proposed fix for the documentation
  of xmlXPathCastToString(); see bug #346202.
2006-08-15 13:04:07 +00:00
Kasimier T. Buchcik
889b76229b Changed xmlXPathCollectAndTest() to use xmlXPathNodeSetAddNs() when adding
* xpath.c: Changed xmlXPathCollectAndTest() to use
  xmlXPathNodeSetAddNs() when adding a ns-node in case of
  NODE_TEST_TYPE (the ns-node was previously added plainly
  to the list). Since for NODE_TEST_ALL and NODE_TEST_NAME
  this specialized ns-addition function was already used,
  I assume it was missed to be used with NODE_TEST_TYPE.
2006-07-03 11:44:13 +00:00
Kasimier T. Buchcik
2bdb12ff9f Fixed a double-free in xmlXPathCompOpEvalToBoolean(), revealed by a
* xpath.c: Fixed a double-free in xmlXPathCompOpEvalToBoolean(),
  revealed by a Libxslt regression test.
2006-06-29 10:49:59 +00:00
Kasimier T. Buchcik
324c75b3c3 Enhanced xmlXPathCompOpEvalToBoolean() to be also usable outside predicate
* xpath.c: Enhanced xmlXPathCompOpEvalToBoolean() to be also
  usable outside predicate evaluation; the intention is to
  use it via xmlXPathCompiledEvalToBoolean() for XSLT tests,
  like in <xsl:if test="/foo">.
2006-06-29 10:31:35 +00:00
Kasimier T. Buchcik
8af1f0bb83 Fix a memory leak which occurred when using
* xpath.c: Fix a memory leak which occurred when using
  xmlXPathCompiledEvalToBoolean().
2006-06-28 17:13:19 +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
6422d916d9 Fixed an bug in xmlXPathCompExprAdd(): the newly introduced field
* xpath.c: Fixed an bug in xmlXPathCompExprAdd(): the newly
  introduced field @rewriteType on xmlXPathStepOp was not
  initialized to zero here; this could lead to the activation
  of the axis rewrite code in xmlXPathNodeCollectAndTest() when
  @rewriteType is randomly set to the value 1. A test
  (hardcoding the intial value to 1) revealed that the
  resulting incorrect behaviour is similar to the behaviour
  as described by Arnold Hendriks on the mailing list; so I
  hope that will fix the issue.
2006-06-26 14:31:53 +00:00
Kasimier T. Buchcik
766ed7e1e5 Fixed an error in xmlXPathEvalExpr(), which was introduced with the
* xpath.c: Fixed an error in xmlXPathEvalExpr(), which
  was introduced with the addition of the d-o-s rewrite
  and made xpath.c unable to compile if XPATH_STREAMING
  was not defined (reported by Kupriyanov Anatolij -
  #345752). Fixed the check for d-o-s rewrite
  to work on the correct XPath string, which is ctxt->base
  and not comp->expr in this case.
2006-06-23 16:32:41 +00:00
Kasimier T. Buchcik
9bca933a6e Added optimization for positional predicates (only short-hand form "[n]"),
* xpath.c: Added optimization for positional predicates
  (only short-hand form "[n]"), which have a preceding
  predicate: "/foo[descendant::bar][3]".
2006-06-19 10:26:42 +00:00
Kasimier T. Buchcik
7cb3fa9d51 Fixed self-invented a segfault in xmlXPathCtxtCompile(), when the
* xpath.c: Fixed self-invented a segfault in xmlXPathCtxtCompile(),
  when the expression was not valid and @comp was NULL and I
  tried to do the d-o-s rewrite.
2006-06-06 15:27:46 +00:00
Kasimier T. Buchcik
080152c901 Enabled the compound traversal again; I added a check to use this only if
* xpath.c: Enabled the compound traversal again; I added a
  check to use this only if the have an expression starting
  with the document node; so in the case of "//foo", we
  already know at compilation-time, that there will be only
  1 initial context node. Added the rewrite also to
  xmlXPathEvalExpr().
2006-06-06 09:42:15 +00:00
Kasimier T. Buchcik
c42e9f6409 Disabled the compound traversal for the release; I need first to assure
* xpath.c: Disabled the compound traversal for the release;
  I need first to assure that this is done only if we have
  1 initial node.
2006-06-02 20:48:50 +00:00
Aleksey Sanin
1b2be101e8 fixed memory leak in xpath error reporting
* xpath.c: fixed memory leak in xpath error reporting
2006-05-31 20:53:43 +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
df0ba26409 Optimized xmlXPathNodeCollectAndTest() and xmlXPathNodeCollectAndTestNth()
* xpath.c: Optimized xmlXPathNodeCollectAndTest() and
  xmlXPathNodeCollectAndTestNth() to evaluate a compound
  traversal of 2 axes when we have a "//foo" expression.
  This is done with a rewrite of the XPath AST in
  xmlXPathRewriteDOSExpression(); I added an additional field
  to xmlXPathStepOp for this (but the field's name should be
  changed). The mechanism: the embracing descendant-or-self
  axis traversal (also optimized to return only nodes which
  can hold elements), will produce context nodes for the
  inner traversal of the child axis. This way we avoid a full
  node-collecting traversal of the descendant-or-self axis.
  Some tests indicate that this can reduce execution time of
  "//foo" to 50%. Together with the XPath object cache this
  all significantly speeds up libxslt.
2006-05-30 19:45:37 +00:00
Kasimier T. Buchcik
75af2a87e5 Enhanced xmlXPathNodeCollectAndTest() to avoid recreation (if possible) of
* xpath.c: Enhanced xmlXPathNodeCollectAndTest() to avoid
  recreation (if possible) of the node-set which is used to
  collect the nodes in the current axis for the currect context
  node. Especially for "//foo" this will decrease dramatically
  the number of created node-sets, since for each node in the
  result node-set of the evaluation of descendant-or-self::node()
  a new temporary node-set was created. Added node iterator
  xmlXPathNextChildElement() as a tiny optimization for
  child::foo.
2006-05-30 09:29:23 +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
Kasimier T. Buchcik
984a9aeddf Removed a memcpy if xmlXPathNodeSetMerge(); it seems we really need to
* xpath.c: Removed a memcpy if xmlXPathNodeSetMerge(); it
  seems we really need to walk the whole list, since those
  nastly namespace nodes need to be added with
  xmlXPathNodeSetDupNs(); thus a pure memcpy is not possible.
  A flag on the node-set indicating if namespace nodes are in
  the set would help here; this is the 3rd flag which would
  be usefull with node-sets. The current flags I have in mind:
  1) Is a node-set already sorted?
     This would allow for rebust and optimizable sorting
     behaviour.
  2) Of what type are the nodes in the set (or of mixed type)?
     This would allow for faster merging of node-sets.
  3) Are namespace nodes in the set?
     This would allow to skipp all the namespace node specific
     special handling. Faster node-set merging if the first
     set is empty; just memcpy the set.
2006-05-24 09:02:35 +00:00
Kasimier T. Buchcik
5691f436d9 Optimization of count(): eliminated sorting (see bug #165547).
* xpath.c: Optimization of count(): eliminated sorting
  (see bug #165547). Optimization of XPATH_OP_FILTER if the
  predicate is a [1] (disable with XP_OPTIMIZED_FILTER_FIRST if
  it produces trouble). Tiny opt in xmlXPathNodeSetMerge().
2006-05-22 15:19:55 +00:00
Kasimier T. Buchcik
64f7e1a85f Substituted all remaining calls to xmlXPathCmpNodes() for
* xpath.c: Substituted all remaining calls to xmlXPathCmpNodes()
  for xmlXPathCmpNodesExt(). Tiny further enhancement of
  xmlXPathCmpNodesExt(). Added additional checks in various code
  parts to avoid calling sorting or merging functions if the
  node-set(s) don't need them; i.e., if they are empty or contain
  just one node.
2006-05-19 19:59:54 +00:00
Kasimier T. Buchcik
2bdabbd711 Optimized the comparison for non-element nodes in xmlXPathCmpNodesExt();
* xpath.c: Optimized the comparison for non-element nodes
  in xmlXPathCmpNodesExt(); the comparison is used for sorting
  of node-sets. This enhancement is related to bug #165547.
  There are other places where the old comparison function
  xmlXPathCmpNodes() is still called, but I currently don't
  know exactly what those calls are for; thus if they can be
  substituted (if it makes sense) for the new function.
2006-05-19 11:26:15 +00:00
Kasimier T. Buchcik
6ed2eb47fc Applied patch from Rob Richards, fixing a potential memory leak in
* xpath.c: Applied patch from Rob Richards, fixing a potential
  memory leak in xmlXPathTryStreamCompile(), when a list of
  namespaces was assigned to the XPath compilation context;
  here a new namespace list was created and passed to
  xmlPatterncompile(); but this list was not freed afterwards.
  Additionally we avoid now in xmlXPathTryStreamCompile() to
  compile the expression, if it has a colon - indicating
  prefixed name tests - and no namespace list was given. The
  streaming XPath mechanism needs a namespace list at
  compilation time (unlike normal XPath, where we can bind
  namespace names to prefixes at execution time).
* pattern.c: Enhanced to use a string dict for local-names,
  ns-prefixes and and namespace-names.
  Fixed xmlStreamPushInternal() not to use string-pointer
  comparison if a dict is available; this won't work, since
  one does not know it the given strings originate from the
  same dict - and they normally don't do, since e.g.
  namespaces are hold on xmlNs->href. I think this would be
  worth an investigation: if we can add a @doc field to xmlNs
  and put the @href in to a additionan namespace dict hold
  in xmlDoc. Daniel will surely not like this idea :-) But
  evaluation of tons of elements/attributes in namespaces
  with xmlStrEqual() isn't the way we should go forever.
2006-05-16 15:13:37 +00:00
Daniel Veillard
aac7c68e87 fix a few warning raised by gcc-4.1 and latests changes Daniel
* c14n.c encoding.c xmlschemas.c xpath.c xpointer.c: fix a few
  warning raised by gcc-4.1 and latests changes
Daniel
2006-03-10 13:40:16 +00:00
Daniel Veillard
11ce4004d8 end of first pass on coverity reports. Daniel
* runtest.c schematron.c testAutomata.c tree.c valid.c xinclude.c
  xmlcatalog.c xmlreader.c xmlregexp.c xpath.c: end of first
  pass on coverity reports.
Daniel
2006-03-10 00:36:23 +00:00
Daniel Veillard
d3ff7ef6d3 workaround HP-UX compiler bug by Rick Jones Daniel
* xpath.c: workaround HP-UX compiler bug by Rick Jones
Daniel
2006-02-27 19:43:17 +00:00
Kasimier T. Buchcik
97258713d3 Fixed bug #322928, reported by Erich Schubert: The bug was in pattern.c,
* pattern.c xpath.c include/libxml/pattern.h:
  Fixed bug #322928, reported by Erich Schubert: The bug was
  in pattern.c, which is used for a tiny subset of xpath
  expression which can be evaluated in an optimized way.
  The doc-node was never considered when evaluating "//"
  expressions. Additionally, we fixed resolution
  to nodes of any type in pattern.c; i.e. a "//." didn't work
  yet, as it did select only element-nodes. Due to this
  issue the pushing of nodes in xpath.c needed to be adjusted
  as well.
2006-01-05 12:30:43 +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
f03a8cdacd fixing yet another pattern induced XPath bug #314282 reverted back last
* pattern.c xpath.c include/libxml/pattern.h: fixing yet another
  pattern induced XPath bug #314282
* relaxng.c: reverted back last change it was seriously broken
Daniel
2005-09-04 12:01:57 +00:00
Daniel Veillard
8bda20f73c removed a potentially uninitialized variable error fixed a deprecation
* xpath.c: removed a potentially uninitialized variable error
* python/generator.py: fixed a deprecation warning
* python/tests/tstLastError.py: silent the damn test when Okay !
Daniel
2005-08-24 09:36:47 +00:00
Daniel Veillard
24505b0f5c a lot of small cleanups based on Linus' sparse check output. Daniel
* HTMLparser.c SAX2.c encoding.c globals.c parser.c relaxng.c
  runsuite.c runtest.c schematron.c testHTML.c testReader.c
  testRegexp.c testSAX.c testThreads.c valid.c xinclude.c xmlIO.c
  xmllint.c xmlmodule.c xmlschemas.c xpath.c xpointer.c: a lot of
  small cleanups based on Linus' sparse check output.
Daniel
2005-07-28 23:49:35 +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
32f0f717d1 Changed the behaviour of xmlXPathEqualNodeSetFloat to return TRUE if a
* xpath.c: Changed the behaviour of xmlXPathEqualNodeSetFloat to
  return TRUE if a nodeset with a numeric value of NaN is compared
  for inequality with any numeric value (bug 309914).
2005-07-14 07:00:33 +00:00
Daniel Veillard
1f33c4d61f preparing to make testsuite releases along with code source releases fixed
* xstc/Makefile.am README README.tests Makefile.tests Makefile.am:
  preparing to make testsuite releases along with code source releases
* gentest.py testapi.c: fixed a couple of problem introduced by
  the new Schemas support for Readers
* xpath.c: fixed the XPath attribute:: bug #309580, #309864 in a crude
  but simple way.
* xmlschemas.c include/libxml/tree.h: fixed a couple of problems
  raised by the doc builder.
* doc/*: made rebuild
Daniel
2005-07-10 21:38:31 +00:00