mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-21 14:53:44 +03:00
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
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
Sun Sep 4 14:01:00 CEST 2005 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* 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
|
||||||
|
|
||||||
Sat Sep 3 16:51:55 CEST 2005 Rob Richards <rrichards@ctindustries.net>
|
Sat Sep 3 16:51:55 CEST 2005 Rob Richards <rrichards@ctindustries.net>
|
||||||
|
|
||||||
* xmlsave.c: check for NULL to prevent crash with meta elements
|
* xmlsave.c: check for NULL to prevent crash with meta elements
|
||||||
|
@@ -66,6 +66,8 @@ XMLPUBFUN int XMLCALL
|
|||||||
xmlPatternStreamable (xmlPatternPtr comp);
|
xmlPatternStreamable (xmlPatternPtr comp);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlPatternMaxDepth (xmlPatternPtr comp);
|
xmlPatternMaxDepth (xmlPatternPtr comp);
|
||||||
|
XMLPUBFUN int XMLCALL
|
||||||
|
xmlPatternMinDepth (xmlPatternPtr comp);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlPatternFromRoot (xmlPatternPtr comp);
|
xmlPatternFromRoot (xmlPatternPtr comp);
|
||||||
XMLPUBFUN xmlStreamCtxtPtr XMLCALL
|
XMLPUBFUN xmlStreamCtxtPtr XMLCALL
|
||||||
|
34
pattern.c
34
pattern.c
@@ -1634,6 +1634,14 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
|
|||||||
* Fast check for ".".
|
* Fast check for ".".
|
||||||
*/
|
*/
|
||||||
if (comp->nbStep == 0) {
|
if (comp->nbStep == 0) {
|
||||||
|
/*
|
||||||
|
* / and . are handled at the XPath node set creation
|
||||||
|
* level by checking min depth
|
||||||
|
*/
|
||||||
|
if (stream->flags & XML_PATTERN_XPATH) {
|
||||||
|
stream = stream->next;
|
||||||
|
continue; /* while */
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* For non-pattern like evaluation like XML Schema IDCs
|
* For non-pattern like evaluation like XML Schema IDCs
|
||||||
* or traditional XPath expressions, this will match if
|
* or traditional XPath expressions, this will match if
|
||||||
@@ -2157,7 +2165,33 @@ xmlPatternMaxDepth(xmlPatternPtr comp) {
|
|||||||
comp = comp->next;
|
comp = comp->next;
|
||||||
}
|
}
|
||||||
return(ret);
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlPatternMinDepth:
|
||||||
|
* @comp: the precompiled pattern
|
||||||
|
*
|
||||||
|
* Check the minimum depth reachable by a pattern, 0 mean the / or . are
|
||||||
|
* part of the set.
|
||||||
|
*
|
||||||
|
* Returns -1 in case of error otherwise the depth,
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xmlPatternMinDepth(xmlPatternPtr comp) {
|
||||||
|
int ret = 12345678;
|
||||||
|
if (comp == NULL)
|
||||||
|
return(-1);
|
||||||
|
while (comp != NULL) {
|
||||||
|
if (comp->stream == NULL)
|
||||||
|
return(-1);
|
||||||
|
if (comp->stream->nbStep < ret)
|
||||||
|
ret = comp->stream->nbStep;
|
||||||
|
if (ret == 0)
|
||||||
|
return(0);
|
||||||
|
comp = comp->next;
|
||||||
|
}
|
||||||
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -2220,6 +2220,9 @@ xmlRelaxNGShowValidError(xmlRelaxNGValidCtxtPtr ctxt,
|
|||||||
{
|
{
|
||||||
xmlChar *msg;
|
xmlChar *msg;
|
||||||
|
|
||||||
|
if (ctxt->error == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef DEBUG_ERROR
|
#ifdef DEBUG_ERROR
|
||||||
xmlGenericError(xmlGenericErrorContext, "Show error %d\n", err);
|
xmlGenericError(xmlGenericErrorContext, "Show error %d\n", err);
|
||||||
#endif
|
#endif
|
||||||
@@ -2329,7 +2332,7 @@ xmlRelaxNGAddValidError(xmlRelaxNGValidCtxtPtr ctxt,
|
|||||||
xmlRelaxNGValidErr err, const xmlChar * arg1,
|
xmlRelaxNGValidErr err, const xmlChar * arg1,
|
||||||
const xmlChar * arg2, int dup)
|
const xmlChar * arg2, int dup)
|
||||||
{
|
{
|
||||||
if (ctxt == NULL)
|
if ((ctxt == NULL) || (ctxt->error == NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef DEBUG_ERROR
|
#ifdef DEBUG_ERROR
|
||||||
|
18
xpath.c
18
xpath.c
@@ -11003,7 +11003,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
|
|||||||
*/
|
*/
|
||||||
static xmlXPathObjectPtr
|
static xmlXPathObjectPtr
|
||||||
xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp) {
|
xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp) {
|
||||||
int max_depth;
|
int max_depth, min_depth;
|
||||||
int from_root;
|
int from_root;
|
||||||
int ret, depth;
|
int ret, depth;
|
||||||
xmlNodePtr cur = NULL, limit = NULL;
|
xmlNodePtr cur = NULL, limit = NULL;
|
||||||
@@ -11019,6 +11019,9 @@ xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp) {
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
if (max_depth == -2)
|
if (max_depth == -2)
|
||||||
max_depth = 10000;
|
max_depth = 10000;
|
||||||
|
min_depth = xmlPatternMinDepth(comp);
|
||||||
|
if (min_depth == -1)
|
||||||
|
return(NULL);
|
||||||
from_root = xmlPatternFromRoot(comp);
|
from_root = xmlPatternFromRoot(comp);
|
||||||
if (from_root < 0)
|
if (from_root < 0)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@@ -11030,13 +11033,20 @@ xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp) {
|
|||||||
if (retval == NULL)
|
if (retval == NULL)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
if ((from_root) && (max_depth == 0)) {
|
/*
|
||||||
|
* handle the special cases of / amd . being matched
|
||||||
|
*/
|
||||||
|
if (min_depth == 0) {
|
||||||
|
if (from_root) {
|
||||||
xmlXPathNodeSetAddUnique(retval->nodesetval, (xmlNodePtr) ctxt->doc);
|
xmlXPathNodeSetAddUnique(retval->nodesetval, (xmlNodePtr) ctxt->doc);
|
||||||
return(retval);
|
} else {
|
||||||
} else if (max_depth == 0) {
|
|
||||||
xmlXPathNodeSetAddUnique(retval->nodesetval, ctxt->node);
|
xmlXPathNodeSetAddUnique(retval->nodesetval, ctxt->node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (max_depth == 0) {
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from_root) {
|
if (from_root) {
|
||||||
cur = (xmlNodePtr)ctxt->doc;
|
cur = (xmlNodePtr)ctxt->doc;
|
||||||
} else if (ctxt->node != NULL) {
|
} else if (ctxt->node != NULL) {
|
||||||
|
Reference in New Issue
Block a user