Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: third_party/libxslt/libxslt/preproc.c

Issue 1193533007: Upgrade to libxml 2.9.2 and libxslt 1.1.28 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no iconv Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libxslt/libxslt/preproc.h ('k') | third_party/libxslt/libxslt/security.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libxslt/libxslt/preproc.c
diff --git a/third_party/libxslt/libxslt/preproc.c b/third_party/libxslt/libxslt/preproc.c
index b47d8099005e5f60dc9b2e769a315412c9ba0f95..4ef3f631d98ace7eb5b3a0c864f2dbb88d9e7b4c 100644
--- a/third_party/libxslt/libxslt/preproc.c
+++ b/third_party/libxslt/libxslt/preproc.c
@@ -39,6 +39,7 @@
#include "extra.h"
#include "imports.h"
#include "extensions.h"
+#include "pattern.h"
#ifdef WITH_XSLT_DEBUG
#define WITH_XSLT_DEBUG_PREPROC
@@ -72,7 +73,7 @@ xsltCheckTopLevelElement(xsltStylesheetPtr style, xmlNodePtr inst, int err) {
xmlNodePtr parent;
if ((style == NULL) || (inst == NULL) || (inst->ns == NULL))
return(-1);
-
+
parent = inst->parent;
if (parent == NULL) {
if (err) {
@@ -115,7 +116,7 @@ xsltCheckInstructionElement(xsltStylesheetPtr style, xmlNodePtr inst) {
return;
has_ext = (style->extInfos != NULL);
-
+
parent = inst->parent;
if (parent == NULL) {
xsltTransformError(NULL, style, inst,
@@ -141,7 +142,7 @@ xsltCheckInstructionElement(xsltStylesheetPtr style, xmlNodePtr inst) {
if ((has_ext) && (parent->ns != NULL) &&
(xmlHashLookup(style->extInfos, parent->ns->href) != NULL))
return;
-
+
parent = parent->parent;
}
xsltTransformError(NULL, style, inst,
@@ -193,7 +194,7 @@ xsltCheckParentElement(xsltStylesheetPtr style, xmlNodePtr inst,
if ((parent->ns != NULL) &&
(xmlHashLookup(style->extInfos, parent->ns->href) != NULL))
return;
-
+
parent = parent->parent;
}
}
@@ -229,7 +230,7 @@ xsltNewStylePreComp(xsltStylesheetPtr style, xsltStyleType type) {
if (style == NULL)
return(NULL);
-
+
#ifdef XSLT_REFACTORED
/*
* URGENT TODO: Use specialized factory functions in order
@@ -280,7 +281,7 @@ xsltNewStylePreComp(xsltStylesheetPtr style, xsltStyleType type) {
size = sizeof(xsltStyleItemWhen); break;
case XSLT_FUNC_OTHERWISE:
size = sizeof(xsltStyleItemOtherwise); break;
- default:
+ default:
xsltTransformError(NULL, style, NULL,
"xsltNewStylePreComp : invalid type %d\n", type);
style->errors++;
@@ -353,8 +354,8 @@ xsltNewStylePreComp(xsltStylesheetPtr style, xsltStyleType type) {
case XSLT_FUNC_DOCUMENT:
cur->func = (xsltTransformFunction) xsltDocumentElem;break;
case XSLT_FUNC_WITHPARAM:
- case XSLT_FUNC_PARAM:
- case XSLT_FUNC_VARIABLE:
+ case XSLT_FUNC_PARAM:
+ case XSLT_FUNC_VARIABLE:
case XSLT_FUNC_WHEN:
break;
default:
@@ -419,7 +420,13 @@ xsltFreeStylePreComp(xsltStylePreCompPtr comp) {
xmlXPathFreeCompExpr(item->comp);
}
break;
- case XSLT_FUNC_NUMBER:
+ case XSLT_FUNC_NUMBER: {
+ xsltStyleItemNumberPtr item = (xsltStyleItemNumberPtr) comp;
+ if (item->numdata.countPat != NULL)
+ xsltFreeCompMatchList(item->numdata.countPat);
+ if (item->numdata.fromPat != NULL)
+ xsltFreeCompMatchList(item->numdata.fromPat);
+ }
break;
case XSLT_FUNC_APPLYIMPORTS:
break;
@@ -477,22 +484,26 @@ xsltFreeStylePreComp(xsltStylePreCompPtr comp) {
xmlXPathFreeCompExpr(item->comp);
}
break;
- case XSLT_FUNC_OTHERWISE:
+ case XSLT_FUNC_OTHERWISE:
case XSLT_FUNC_FALLBACK:
case XSLT_FUNC_MESSAGE:
case XSLT_FUNC_INCLUDE:
case XSLT_FUNC_ATTRSET:
-
+
break;
default:
/* TODO: Raise error. */
break;
}
-#else
+#else
if (comp->locale != (xsltLocale)0)
xsltFreeLocale(comp->locale);
if (comp->comp != NULL)
xmlXPathFreeCompExpr(comp->comp);
+ if (comp->numdata.countPat != NULL)
+ xsltFreeCompMatchList(comp->numdata.countPat);
+ if (comp->numdata.fromPat != NULL)
+ xsltFreeCompMatchList(comp->numdata.fromPat);
if (comp->nsList != NULL)
xmlFree(comp->nsList);
#endif
@@ -545,7 +556,7 @@ xsltDocumentComp(xsltStylesheetPtr style, xmlNodePtr inst,
#else
comp = xsltNewStylePreComp(style, XSLT_FUNC_DOCUMENT);
#endif
-
+
if (comp == NULL)
return (NULL);
comp->inst = inst;
@@ -592,8 +603,8 @@ xsltDocumentComp(xsltStylesheetPtr style, xmlNodePtr inst,
#ifdef WITH_XSLT_DEBUG_EXTRA
xsltGenericDebug(xsltGenericDebugContext,
"Found xslt11:document construct\n");
-#endif
- } else {
+#endif
+ } else {
if (xmlStrEqual(inst->ns->href,
(const xmlChar *)"http://exslt.org/common")) {
/* EXSLT. */
@@ -634,12 +645,12 @@ xsltDocumentComp(xsltStylesheetPtr style, xmlNodePtr inst,
* 3) XSLT_XT_NAMESPACE (http://www.jclark.com/xt)
* Example: <xt:document method="xml" href="myFile.xml">
* TODO: is @href is an AVT?
- *
+ *
* In all cases @href is in no namespace.
*/
filename = xsltEvalStaticAttrValueTemplate(style, inst,
(const xmlChar *)"href", NULL, &comp->has_filename);
- }
+ }
if (!comp->has_filename) {
goto error;
}
@@ -669,7 +680,7 @@ xsltSortComp(xsltStylesheetPtr style, xmlNodePtr inst) {
#else
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -677,7 +688,7 @@ xsltSortComp(xsltStylesheetPtr style, xmlNodePtr inst) {
#else
comp = xsltNewStylePreComp(style, XSLT_FUNC_SORT);
#endif
-
+
if (comp == NULL)
return;
inst->psvi = comp;
@@ -777,14 +788,14 @@ xsltCopyComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
comp = (xsltStyleItemCopyPtr) xsltNewStylePreComp(style, XSLT_FUNC_COPY);
#else
comp = xsltNewStylePreComp(style, XSLT_FUNC_COPY);
#endif
-
+
if (comp == NULL)
return;
inst->psvi = comp;
@@ -821,14 +832,14 @@ xsltTextComp(xsltStylesheetPtr style, xmlNodePtr inst) {
#endif
const xmlChar *prop;
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
comp = (xsltStyleItemTextPtr) xsltNewStylePreComp(style, XSLT_FUNC_TEXT);
#else
comp = xsltNewStylePreComp(style, XSLT_FUNC_TEXT);
-#endif
+#endif
if (comp == NULL)
return;
inst->psvi = comp;
@@ -874,7 +885,7 @@ xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst) {
* <!-- Content: template -->
* </xsl:element>
*/
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -910,8 +921,8 @@ xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst) {
*/
comp->ns = xsltEvalStaticAttrValueTemplate(style, inst,
(const xmlChar *)"namespace", NULL, &comp->has_ns);
-
- if (comp->name != NULL) {
+
+ if (comp->name != NULL) {
if (xmlValidateQName(comp->name, 0)) {
xsltTransformError(NULL, style, inst,
"xsl:element: The value '%s' of the attribute 'name' is "
@@ -921,7 +932,7 @@ xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst) {
const xmlChar *prefix = NULL, *name;
name = xsltSplitQName(style->dict, comp->name, &prefix);
- if (comp->has_ns == 0) {
+ if (comp->has_ns == 0) {
xmlNsPtr ns;
/*
@@ -930,7 +941,7 @@ xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst) {
* expanded into an expanded-name using the namespace declarations
* in effect for the xsl:element element, including any default
* namespace declaration.
- */
+ */
ns = xmlSearchNs(inst->doc, inst, prefix);
if (ns != NULL) {
comp->ns = xmlDictLookup(style->dict, ns->href, -1);
@@ -947,17 +958,17 @@ xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst) {
"not specified by the instruction itself.\n", comp->name);
style->errors++;
}
- }
+ }
if ((prefix != NULL) &&
(!xmlStrncasecmp(prefix, (xmlChar *)"xml", 3)))
{
/*
* Mark is to be skipped.
*/
- comp->has_name = 0;
+ comp->has_name = 0;
}
}
- }
+ }
/*
* Attribute "use-attribute-sets",
*/
@@ -965,7 +976,7 @@ xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst) {
(const xmlChar *)"use-attribute-sets",
NULL, &comp->has_use);
-error:
+error:
return;
}
@@ -991,7 +1002,7 @@ xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst) {
* <!-- Content: template -->
* </xsl:attribute>
*/
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1000,7 +1011,7 @@ xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst) {
#else
comp = xsltNewStylePreComp(style, XSLT_FUNC_ATTRIBUTE);
#endif
-
+
if (comp == NULL)
return;
inst->psvi = comp;
@@ -1020,7 +1031,7 @@ xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst) {
"XSLT-attribute: The attribute 'name' is missing.\n");
style->errors++;
return;
- }
+ }
/*
* Attribute "namespace".
*/
@@ -1037,6 +1048,10 @@ xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst) {
"xsl:attribute: The value '%s' of the attribute 'name' is "
"not a valid QName.\n", comp->name);
style->errors++;
+ } else if (xmlStrEqual(comp->name, BAD_CAST "xmlns")) {
+ xsltTransformError(NULL, style, inst,
+ "xsl:attribute: The attribute name 'xmlns' is not allowed.\n");
+ style->errors++;
} else {
const xmlChar *prefix = NULL, *name;
@@ -1051,7 +1066,7 @@ xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst) {
* QName is expanded into an expanded-name using the
* namespace declarations in effect for the xsl:element
* element, including any default namespace declaration.
- */
+ */
ns = xmlSearchNs(inst->doc, inst, prefix);
if (ns != NULL) {
comp->ns = xmlDictLookup(style->dict, ns->href, -1);
@@ -1070,29 +1085,8 @@ xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst) {
style->errors++;
}
}
- if (!xmlStrncasecmp(prefix, (xmlChar *) "xmlns", 5)) {
- /*
- * SPEC XSLT 1.0:
- * "It is an error if the string that results from
- * instantiating the attribute value template is not a
- * QName or is the string xmlns. An XSLT processor may
- * signal the error; if it does not signal the error,
- * it must recover by not adding the attribute to the
- * result tree."
- *
- * Reject a prefix of "xmlns". Mark to be skipped.
- */
- comp->has_name = 0;
-
-#ifdef WITH_XSLT_DEBUG_PARSING
- xsltGenericDebug(xsltGenericDebugContext,
- "xsltAttribute: xmlns prefix forbidden\n");
-#endif
- return;
- }
-
}
- }
+ }
}
}
@@ -1111,7 +1105,7 @@ xsltCommentComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1141,7 +1135,7 @@ xsltProcessingInstructionComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1175,7 +1169,7 @@ xsltCopyOfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1222,7 +1216,7 @@ xsltValueOfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
#endif
const xmlChar *prop;
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1347,7 +1341,7 @@ xsltWithParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1406,7 +1400,7 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
#endif
const xmlChar *prop;
- if ((style == NULL) || (cur == NULL))
+ if ((style == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1426,7 +1420,7 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
comp->numdata.node = cur;
comp->numdata.value = xsltGetCNsProp(style, cur, (const xmlChar *)"value",
XSLT_NAMESPACE);
-
+
prop = xsltEvalStaticAttrValueTemplate(style, cur,
(const xmlChar *)"format",
XSLT_NAMESPACE, &comp->numdata.has_format);
@@ -1437,10 +1431,22 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
}
comp->numdata.count = xsltGetCNsProp(style, cur, (const xmlChar *)"count",
- XSLT_NAMESPACE);
+ XSLT_NAMESPACE);
comp->numdata.from = xsltGetCNsProp(style, cur, (const xmlChar *)"from",
- XSLT_NAMESPACE);
-
+ XSLT_NAMESPACE);
+
+ prop = xsltGetCNsProp(style, cur, (const xmlChar *)"count", XSLT_NAMESPACE);
+ if (prop != NULL) {
+ comp->numdata.countPat = xsltCompilePattern(prop, cur->doc, cur, style,
+ NULL);
+ }
+
+ prop = xsltGetCNsProp(style, cur, (const xmlChar *)"from", XSLT_NAMESPACE);
+ if (prop != NULL) {
+ comp->numdata.fromPat = xsltCompilePattern(prop, cur->doc, cur, style,
+ NULL);
+ }
+
prop = xsltGetCNsProp(style, cur, (const xmlChar *)"level", XSLT_NAMESPACE);
if (prop != NULL) {
if (xmlStrEqual(prop, BAD_CAST("single")) ||
@@ -1453,14 +1459,14 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
if (style != NULL) style->warnings++;
}
}
-
+
prop = xsltGetCNsProp(style, cur, (const xmlChar *)"lang", XSLT_NAMESPACE);
if (prop != NULL) {
xsltTransformError(NULL, style, cur,
"xsl:number : lang attribute not implemented\n");
XSLT_TODO; /* xsl:number lang attribute */
}
-
+
prop = xsltGetCNsProp(style, cur, (const xmlChar *)"letter-value", XSLT_NAMESPACE);
if (prop != NULL) {
if (xmlStrEqual(prop, BAD_CAST("alphabetic"))) {
@@ -1479,7 +1485,7 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
if (style != NULL) style->warnings++;
}
}
-
+
prop = xsltGetCNsProp(style, cur, (const xmlChar *)"grouping-separator",
XSLT_NAMESPACE);
if (prop != NULL) {
@@ -1487,7 +1493,7 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
comp->numdata.groupingCharacter =
xsltGetUTF8Char(prop, &(comp->numdata.groupingCharacterLen));
}
-
+
prop = xsltGetCNsProp(style, cur, (const xmlChar *)"grouping-size", XSLT_NAMESPACE);
if (prop != NULL) {
sscanf((char *)prop, "%d", &comp->numdata.digitsPerGroup);
@@ -1502,7 +1508,7 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
BAD_CAST"single", 6);
}
}
-
+
}
/**
@@ -1520,7 +1526,7 @@ xsltApplyImportsComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1550,7 +1556,7 @@ xsltCallTemplateComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1589,7 +1595,7 @@ xsltApplyTemplatesComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1641,7 +1647,7 @@ xsltChooseComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1672,7 +1678,7 @@ xsltIfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1718,7 +1724,7 @@ xsltWhenComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1764,7 +1770,7 @@ xsltForEachComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1812,7 +1818,7 @@ xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1837,13 +1843,16 @@ xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltGetQNameProperty(style, inst, BAD_CAST "name",
1, &(comp->has_name), &(comp->ns), &(comp->name));
if (comp->ns)
- comp->has_ns = 1;
+ comp->has_ns = 1;
/*
* Attribute "select".
*/
comp->select = xsltGetCNsProp(style, inst, (const xmlChar *)"select",
XSLT_NAMESPACE);
if (comp->select != NULL) {
+#ifndef XSLT_REFACTORED
+ xmlNodePtr cur;
+#endif
comp->comp = xsltXPathCompile(style, comp->select);
if (comp->comp == NULL) {
xsltTransformError(NULL, style, inst,
@@ -1851,12 +1860,25 @@ xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst) {
comp->select);
style->errors++;
}
+#ifdef XSLT_REFACTORED
if (inst->children != NULL) {
xsltTransformError(NULL, style, inst,
- "XSLT-variable: The must be no child nodes, since the "
+ "XSLT-variable: There must be no child nodes, since the "
"attribute 'select' was specified.\n");
style->errors++;
}
+#else
+ for (cur = inst->children; cur != NULL; cur = cur->next) {
+ if (cur->type != XML_COMMENT_NODE &&
+ (cur->type != XML_TEXT_NODE || !xsltIsBlank(cur->content)))
+ {
+ xsltTransformError(NULL, style, inst,
+ "XSLT-variable: There must be no child nodes, since the "
+ "attribute 'select' was specified.\n");
+ style->errors++;
+ }
+ }
+#endif
}
}
@@ -1875,7 +1897,7 @@ xsltParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
xsltStylePreCompPtr comp;
#endif
- if ((style == NULL) || (inst == NULL))
+ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return;
#ifdef XSLT_REFACTORED
@@ -1936,11 +1958,11 @@ xsltFreeStylePreComps(xsltStylesheetPtr style) {
xsltElemPreCompPtr cur, next;
if (style == NULL)
- return;
-
+ return;
+
cur = style->preComps;
while (cur != NULL) {
- next = cur->next;
+ next = cur->next;
if (cur->type == XSLT_FUNC_EXTENSION)
cur->free(cur);
else
@@ -1962,12 +1984,12 @@ xsltFreeStylePreComps(xsltStylesheetPtr style) {
*/
void
xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr node) {
- /*
+ /*
* The xsltXSLTElemMarker marker was set beforehand by
* the parsing mechanism for all elements in the XSLT namespace.
*/
if (style == NULL) {
- if (node != NULL)
+ if ((node != NULL) && (node->type == XML_ELEMENT_NODE))
node->psvi = NULL;
return;
}
@@ -1982,67 +2004,67 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr node) {
case XSLT_FUNC_APPLYTEMPLATES:
xsltApplyTemplatesComp(style, node);
break;
- case XSLT_FUNC_WITHPARAM:
+ case XSLT_FUNC_WITHPARAM:
xsltWithParamComp(style, node);
break;
- case XSLT_FUNC_VALUEOF:
+ case XSLT_FUNC_VALUEOF:
xsltValueOfComp(style, node);
break;
- case XSLT_FUNC_COPY:
+ case XSLT_FUNC_COPY:
xsltCopyComp(style, node);
break;
case XSLT_FUNC_COPYOF:
xsltCopyOfComp(style, node);
break;
- case XSLT_FUNC_IF:
+ case XSLT_FUNC_IF:
xsltIfComp(style, node);
break;
- case XSLT_FUNC_CHOOSE:
+ case XSLT_FUNC_CHOOSE:
xsltChooseComp(style, node);
break;
- case XSLT_FUNC_WHEN:
+ case XSLT_FUNC_WHEN:
xsltWhenComp(style, node);
break;
- case XSLT_FUNC_OTHERWISE:
+ case XSLT_FUNC_OTHERWISE:
/* NOP yet */
return;
- case XSLT_FUNC_FOREACH:
+ case XSLT_FUNC_FOREACH:
xsltForEachComp(style, node);
break;
- case XSLT_FUNC_APPLYIMPORTS:
+ case XSLT_FUNC_APPLYIMPORTS:
xsltApplyImportsComp(style, node);
break;
- case XSLT_FUNC_ATTRIBUTE:
+ case XSLT_FUNC_ATTRIBUTE:
xsltAttributeComp(style, node);
break;
- case XSLT_FUNC_ELEMENT:
+ case XSLT_FUNC_ELEMENT:
xsltElementComp(style, node);
break;
- case XSLT_FUNC_SORT:
+ case XSLT_FUNC_SORT:
xsltSortComp(style, node);
break;
- case XSLT_FUNC_COMMENT:
+ case XSLT_FUNC_COMMENT:
xsltCommentComp(style, node);
break;
- case XSLT_FUNC_NUMBER:
+ case XSLT_FUNC_NUMBER:
xsltNumberComp(style, node);
break;
- case XSLT_FUNC_PI:
+ case XSLT_FUNC_PI:
xsltProcessingInstructionComp(style, node);
break;
- case XSLT_FUNC_CALLTEMPLATE:
+ case XSLT_FUNC_CALLTEMPLATE:
xsltCallTemplateComp(style, node);
break;
- case XSLT_FUNC_PARAM:
+ case XSLT_FUNC_PARAM:
xsltParamComp(style, node);
break;
- case XSLT_FUNC_VARIABLE:
+ case XSLT_FUNC_VARIABLE:
xsltVariableComp(style, node);
break;
- case XSLT_FUNC_FALLBACK:
+ case XSLT_FUNC_FALLBACK:
/* NOP yet */
return;
- case XSLT_FUNC_DOCUMENT:
+ case XSLT_FUNC_DOCUMENT:
/* The extra one */
node->psvi = (void *) xsltDocumentComp(style, node,
(xsltTransformFunction) xsltDocumentElem);
@@ -2065,7 +2087,7 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr node) {
} else {
/*
* Fallback to string comparison.
- */
+ */
if (IS_XSLT_NAME(node, "apply-templates")) {
xsltApplyTemplatesComp(style, node);
} else if (IS_XSLT_NAME(node, "with-param")) {
@@ -2081,7 +2103,7 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr node) {
} else if (IS_XSLT_NAME(node, "choose")) {
xsltChooseComp(style, node);
} else if (IS_XSLT_NAME(node, "when")) {
- xsltWhenComp(style, node);
+ xsltWhenComp(style, node);
} else if (IS_XSLT_NAME(node, "otherwise")) {
/* NOP yet */
return;
@@ -2113,7 +2135,7 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr node) {
} else if (IS_XSLT_NAME(node, "document")) {
/* The extra one */
node->psvi = (void *) xsltDocumentComp(style, node,
- (xsltTransformFunction) xsltDocumentElem);
+ (xsltTransformFunction) xsltDocumentElem);
} else if (IS_XSLT_NAME(node, "output")) {
/* Top-level */
return;
@@ -2122,7 +2144,7 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr node) {
return;
} else if (IS_XSLT_NAME(node, "strip-space")) {
/* Top-level */
- return;
+ return;
} else if (IS_XSLT_NAME(node, "key")) {
/* Top-level */
return;
@@ -2138,7 +2160,7 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr node) {
/* Top-level */
return;
} else if (IS_XSLT_NAME(node, "include")) {
- /* Top-level */
+ /* Top-level */
} else {
/*
* NOTE that xsl:text, xsl:template, xsl:stylesheet,
@@ -2150,7 +2172,7 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr node) {
"the XSLT element '%s'.\n", node->name);
style->errors++;
return;
- }
+ }
}
/*
* Assign the current list of in-scope namespaces to the
@@ -2182,7 +2204,8 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst) {
* namespace- and local-name of the node, but can evaluate this
* using cctxt->style->inode->category;
*/
- if (inst->psvi != NULL)
+ if ((inst == NULL) || (inst->type != XML_ELEMENT_NODE) ||
+ (inst->psvi != NULL))
return;
if (IS_XSLT_ELEM(inst)) {
@@ -2251,7 +2274,7 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst) {
} else if (IS_XSLT_NAME(inst, "call-template")) {
xsltCheckInstructionElement(style, inst);
xsltCallTemplateComp(style, inst);
- } else if (IS_XSLT_NAME(inst, "param")) {
+ } else if (IS_XSLT_NAME(inst, "param")) {
if (xsltCheckTopLevelElement(style, inst, 0) == 0)
xsltCheckInstructionElement(style, inst);
xsltParamComp(style, inst);
@@ -2319,7 +2342,7 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst) {
"xsltStylePreCompute: unknown xsl:%s\n", inst->name);
if (style != NULL) style->warnings++;
}
-
+
cur = (xsltStylePreCompPtr) inst->psvi;
/*
* A ns-list is build for every XSLT item in the
« no previous file with comments | « third_party/libxslt/libxslt/preproc.h ('k') | third_party/libxslt/libxslt/security.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698