Commit f1454777 authored by Alexandre Julliard's avatar Alexandre Julliard

xslt: Import upstream release 1.1.39.

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