Commit f1454777 authored by Alexandre Julliard's avatar Alexandre Julliard

xslt: Import upstream release 1.1.39.

parent 72b78669
......@@ -12,6 +12,7 @@
#define IN_LIBXSLT
#include "libxslt.h"
#include <stdlib.h>
#include <string.h>
#include <limits.h>
......@@ -26,6 +27,7 @@
#endif
#include <libxml/list.h>
#include <libxml/xmlIO.h>
#include <libxml/threads.h>
#include "xslt.h"
#include "xsltInternals.h"
#include "xsltlocale.h"
......@@ -809,17 +811,13 @@ xsltStyleGetExtData(xsltStylesheetPtr style, const xmlChar * URI)
* Old behaviour.
*/
tmpStyle = style;
while (tmpStyle != NULL) {
if (tmpStyle->extInfos != NULL) {
dataContainer =
(xsltExtDataPtr) xmlHashLookup(tmpStyle->extInfos, URI);
if (dataContainer != NULL) {
return(dataContainer->extData);
}
}
tmpStyle = xsltNextImport(tmpStyle);
if (tmpStyle->extInfos != NULL) {
dataContainer =
(xsltExtDataPtr) xmlHashLookup(tmpStyle->extInfos, URI);
if (dataContainer != NULL) {
return(dataContainer->extData);
}
}
tmpStyle = style;
#endif
dataContainer =
......@@ -2351,32 +2349,34 @@ xsltDebugDumpExtensions(FILE * output)
output = stdout;
fprintf(output,
"Registered XSLT Extensions\n--------------------------\n");
if (!xsltFunctionsHash)
xmlMutexLock(xsltExtMutex);
if (!xsltFunctionsHash) {
fprintf(output, "No registered extension functions\n");
else {
fprintf(output, "Registered Extension Functions:\n");
xmlMutexLock(xsltExtMutex);
} else {
fprintf(output, "Registered extension functions:\n");
xmlHashScanFull(xsltFunctionsHash, xsltDebugDumpExtensionsCallback,
output);
xmlMutexUnlock(xsltExtMutex);
}
if (!xsltElementsHash)
fprintf(output, "\nNo registered extension elements\n");
else {
fprintf(output, "\nRegistered Extension Elements:\n");
xmlMutexLock(xsltExtMutex);
if (!xsltTopLevelsHash) {
fprintf(output, "\nNo registered top-level extension elements\n");
} else {
fprintf(output, "\nRegistered top-level extension elements:\n");
xmlHashScanFull(xsltTopLevelsHash, xsltDebugDumpExtensionsCallback,
output);
}
if (!xsltElementsHash) {
fprintf(output, "\nNo registered instruction extension elements\n");
} else {
fprintf(output, "\nRegistered instruction extension elements:\n");
xmlHashScanFull(xsltElementsHash, xsltDebugDumpExtensionsCallback,
output);
xmlMutexUnlock(xsltExtMutex);
}
if (!xsltExtensionsHash)
if (!xsltExtensionsHash) {
fprintf(output, "\nNo registered extension modules\n");
else {
fprintf(output, "\nRegistered Extension Modules:\n");
xmlMutexLock(xsltExtMutex);
} else {
fprintf(output, "\nRegistered extension modules:\n");
xmlHashScanFull(xsltExtensionsHash, xsltDebugDumpExtModulesCallback,
output);
xmlMutexUnlock(xsltExtMutex);
}
xmlMutexUnlock(xsltExtMutex);
}
......@@ -15,7 +15,7 @@
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/hash.h>
#include <libxml/xmlerror.h>
#include <libxml/uri.h>
......@@ -53,29 +53,49 @@ static void xsltFixImportedCompSteps(xsltStylesheetPtr master,
}
}
#define XSLT_MAX_NESTING 40
static int
xsltCheckCycle(xsltStylesheetPtr style, const xmlChar *URI) {
xsltCheckCycle(xsltStylesheetPtr style, xmlNodePtr cur, const xmlChar *URI) {
xsltStylesheetPtr ancestor;
xsltDocumentPtr docptr;
int depth;
/*
* in order to detect recursion, we check all previously included
* stylesheets.
*/
docptr = style->includes;
while (docptr != NULL) {
if (xmlStrEqual(docptr->doc->URL, URI))
return(-1);
docptr = docptr->includes;
}
/*
* Also check imported stylesheets.
* Check imported stylesheets.
*/
depth = 0;
ancestor = style;
while (ancestor != NULL) {
if (xmlStrEqual(ancestor->doc->URL, URI))
if (++depth >= XSLT_MAX_NESTING) {
xsltTransformError(NULL, style, cur,
"maximum nesting depth exceeded: %s\n", URI);
return(-1);
}
if (xmlStrEqual(ancestor->doc->URL, URI)) {
xsltTransformError(NULL, style, cur,
"recursion detected on imported URL %s\n", URI);
return(-1);
}
/*
* Check included stylesheets.
*/
docptr = ancestor->includes;
while (docptr != NULL) {
if (++depth >= XSLT_MAX_NESTING) {
xsltTransformError(NULL, style, cur,
"maximum nesting depth exceeded: %s\n", URI);
return(-1);
}
if (xmlStrEqual(docptr->doc->URL, URI)) {
xsltTransformError(NULL, style, cur,
"recursion detected on included URL %s\n", URI);
return(-1);
}
docptr = docptr->includes;
}
ancestor = ancestor->parent;
}
......@@ -120,11 +140,8 @@ xsltParseStylesheetImport(xsltStylesheetPtr style, xmlNodePtr cur) {
goto error;
}
if (xsltCheckCycle(style, URI) < 0) {
xsltTransformError(NULL, style, cur,
"xsl:import : recursion detected on imported URL %s\n", URI);
if (xsltCheckCycle(style, cur, URI) < 0)
goto error;
}
/*
* Security framework check
......@@ -213,11 +230,8 @@ xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur) {
goto error;
}
if (xsltCheckCycle(style, URI) < 0) {
xsltTransformError(NULL, style, cur,
"xsl:include : recursion detected on included URL %s\n", URI);
if (xsltCheckCycle(style, cur, URI) < 0)
goto error;
}
include = xsltLoadStyleDocument(style, URI);
if (include == NULL) {
......@@ -406,4 +420,3 @@ xsltFindTemplate(xsltTransformContextPtr ctxt, const xmlChar *name,
}
return(NULL);
}
......@@ -37,7 +37,7 @@
#endif
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/uri.h>
#include "xslt.h"
#include "xsltInternals.h"
......@@ -463,4 +463,3 @@ xsltCheckRead(xsltSecurityPrefsPtr sec,
xmlFreeURI(uri);
return(1);
}
......@@ -1992,7 +1992,21 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node,
case XML_ELEMENT_NODE:
ctxt->xpathCtxt->contextSize = nbchild;
ctxt->xpathCtxt->proximityPosition = childno;
if (ctxt->depth >= ctxt->maxTemplateDepth) {
xsltTransformError(ctxt, NULL, cur,
"xsltDefaultProcessOneNode: Maximum template depth "
"exceeded.\n"
"You can adjust xsltMaxDepth (--maxdepth) in order to "
"raise the maximum number of nested template calls and "
"variables/params (currently set to %d).\n",
ctxt->maxTemplateDepth);
ctxt->state = XSLT_STATE_STOPPED;
return;
}
ctxt->depth++;
xsltProcessOneNode(ctxt, cur, params);
ctxt->depth--;
break;
case XML_CDATA_SECTION_NODE:
template = xsltGetTemplate(ctxt, cur, NULL);
......
......@@ -20,21 +20,21 @@ extern "C" {
*
* the version string like "1.2.3"
*/
#define LIBXSLT_DOTTED_VERSION "1.1.38"
#define LIBXSLT_DOTTED_VERSION "1.1.39"
/**
* LIBXSLT_VERSION:
*
* the version number: 1.2.3 value is 10203
*/
#define LIBXSLT_VERSION 10138
#define LIBXSLT_VERSION 10139
/**
* LIBXSLT_VERSION_STRING:
*
* the version number string, 1.2.3 value is "10203"
*/
#define LIBXSLT_VERSION_STRING "10138"
#define LIBXSLT_VERSION_STRING "10139"
/**
* LIBXSLT_VERSION_EXTRA:
......
......@@ -15,6 +15,7 @@
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/threads.h>
#include "xsltlocale.h"
#include "xsltutils.h"
......
......@@ -14,6 +14,10 @@
#include <libxml/xmlstring.h>
#include "xsltexports.h"
#ifdef __cplusplus
extern "C" {
#endif
XSLTPUBFUN void * XSLTCALL
xsltNewLocale (const xmlChar *langName,
int lowerFirst);
......@@ -33,4 +37,8 @@ XSLTPUBFUN int XSLTCALL
const xmlChar *str1,
const xmlChar *str2);
#ifdef __cplusplus
}
#endif
#endif /* __XML_XSLTLOCALE_H__ */
......@@ -164,7 +164,7 @@ XSLTPUBFUN void XSLTCALL
xsltSetTransformErrorFunc (xsltTransformContextPtr ctxt,
void *ctx,
xmlGenericErrorFunc handler);
XSLTPUBFUN void WINAPIV
XSLTPUBFUN void XSLTCALL
xsltTransformError (xsltTransformContextPtr ctxt,
xsltStylesheetPtr style,
xmlNodePtr node,
......@@ -339,5 +339,3 @@ XSLTPUBFUN void XSLTCALL
#endif
#endif /* __XML_XSLTUTILS_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment