From 386a729acf0786079f4cacf3e4f6a852bb0064e3 Mon Sep 17 00:00:00 2001 From: "William M. Brack" Date: Wed, 26 Nov 2003 01:51:41 +0000 Subject: [PATCH] Changed to detect recursion in xslt:include (bug #127687). * libxslt/imports.c, libxslt/xsltInternals.h: Changed to detect recursion in xslt:include (bug #127687). * tests/XSLTMark/reverser.out, * test/docbook/result/xhtml/gdp-handbook.xhtml: results changed because of fix of bug #127877 in libxml2 (quotes in text) --- ChangeLog | 8 + libxslt/imports.c | 19 ++ libxslt/xsltInternals.h | 6 + tests/XSLTMark/reverser.out | 2 +- tests/docbook/result/xhtml/gdp-handbook.xhtml | 454 +++++++++++++------------- 5 files changed, 261 insertions(+), 228 deletions(-) diff --git a/ChangeLog b/ChangeLog index 447acec..3777425 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Nov 26 09:49:11 HKT 2003 William Brack + + * libxslt/imports.c, libxslt/xsltInternals.h: Changed to + detect recursion in xslt:include (bug #127687). + * tests/XSLTMark/reverser.out, + * test/docbook/result/xhtml/gdp-handbook.xhtml: results changed + because of fix of bug #127877 in libxml2 (quotes in text) + Mon Nov 24 07:32:38 HKT 2003 William Brack * libxslt/xslt.c, libxslt/imports.c, libxslt/parserInternals.h: diff --git a/libxslt/imports.c b/libxslt/imports.c index e624d9e..9bc9a3e 100644 --- a/libxslt/imports.c +++ b/libxslt/imports.c @@ -171,6 +171,7 @@ xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur) { xmlChar *uriRef = NULL; xmlChar *URI = NULL; xsltDocumentPtr include; + xsltDocumentPtr docptr; if ((cur == NULL) || (style == NULL)) return (ret); @@ -190,6 +191,20 @@ xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur) { goto error; } + /* + * in order to detect recursion, we check all previously included + * stylesheets. + */ + docptr = style->includes; + while (docptr != NULL) { + if (xmlStrEqual(docptr->doc->URL, URI)) { + xsltTransformError(NULL, style, cur, + "xsl:include : recursion detected on included URL %s\n", URI); + goto error; + } + docptr = docptr->includes; + } + include = xsltLoadStyleDocument(style, URI); if (include == NULL) { xsltTransformError(NULL, style, cur, @@ -199,7 +214,11 @@ xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur) { oldDoc = style->doc; style->doc = include->doc; + /* chain to stylesheet for recursion checking */ + include->includes = style->includes; + style->includes = include; ret = (int)xsltParseStylesheetProcess(style, include->doc); + style->includes = include->includes; style->doc = oldDoc; if (ret == 0) { ret = -1; diff --git a/libxslt/xsltInternals.h b/libxslt/xsltInternals.h index 5cf478b..ba31b8b 100644 --- a/libxslt/xsltInternals.h +++ b/libxslt/xsltInternals.h @@ -141,6 +141,7 @@ struct _xsltDocument { int main; /* is this the main document */ xmlDocPtr doc; /* the parsed document */ void *keys; /* key tables storage */ + struct _xsltDocument *includes; /* subsidiary includes */ }; typedef struct _xsltTransformContext xsltTransformContext; @@ -414,6 +415,11 @@ struct _xsltStylesheet { */ xmlHashTablePtr extInfos; /* the extension data */ int extrasNr; /* the number of extras required */ + + /* + * For keeping track of nested includes + */ + xsltDocumentPtr includes; /* points to last nested include */ }; /* diff --git a/tests/XSLTMark/reverser.out b/tests/XSLTMark/reverser.out index 87f3ef3..8669ccd 100644 --- a/tests/XSLTMark/reverser.out +++ b/tests/XSLTMark/reverser.out @@ -1,2 +1,2 @@ -earth. the from perish not shall people, the for people the by people the of government that and freedom, of birth new a have shall nation, the that vain; in died have not shall dead these resolve highly here we that -- devotion of measure full last the gave here, they which for cause that to devotion increased take we dead honored these from that, -- us before remaining task great the to dedicated be here we living, the us, for rather is It here. did they what forget never can it while here; say we what remember long nor note, little will world The detract. or add to power poor our above far it, hallowed have here, struggled who dead, and living men, brave The -- ground this hallow, not can we -- consecrate not can we -- dedicate not can we sense, larger a in But, do. propriety all in may, we This live. might nation the that here, died who those for place resting final a as it, of portion a dedicate to come We war. that of field battle great a on met are We endure. long can dedicated, so and conceived, so nation any or nation, that whether testing war, civil great a in engaged are we Now equal" created are men "all that proposition the to dedicated and liberty, in conceived nation, new a continent, this upon forth, brought fathers our ago years seven and score Four +earth. the from perish not shall people, the for people the by people the of government that and freedom, of birth new a have shall nation, the that vain; in died have not shall dead these resolve highly here we that -- devotion of measure full last the gave here, they which for cause that to devotion increased take we dead honored these from that, -- us before remaining task great the to dedicated be here we living, the us, for rather is It here. did they what forget never can it while here; say we what remember long nor note, little will world The detract. or add to power poor our above far it, hallowed have here, struggled who dead, and living men, brave The -- ground this hallow, not can we -- consecrate not can we -- dedicate not can we sense, larger a in But, do. propriety all in may, we This live. might nation the that here, died who those for place resting final a as it, of portion a dedicate to come We war. that of field battle great a on met are We endure. long can dedicated, so and conceived, so nation any or nation, that whether testing war, civil great a in engaged are we Now equal" created are men "all that proposition the to dedicated and liberty, in conceived nation, new a continent, this upon forth, brought fathers our ago years seven and score Four diff --git a/tests/docbook/result/xhtml/gdp-handbook.xhtml b/tests/docbook/result/xhtml/gdp-handbook.xhtml index a488c24..dff9a72 100644 --- a/tests/docbook/result/xhtml/gdp-handbook.xhtml +++ b/tests/docbook/result/xhtml/gdp-handbook.xhtml @@ -84,14 +84,14 @@ irc.gnome.org is another option for contacting GDP members.

This Handbook uses the following notation: -

/usr/bin +

The most frequently asked question of new contributors who - join the GDP is "which document should I start - with?". Because most people involved are volunteers, we do + join the GDP is "which document should I start + with?". Because most people involved are volunteers, we do not assign projects and applications to write documents for. The first step is all yours - you must decide what about GNOME interests you most and find out if @@ -148,7 +148,7 @@ help. The DocTable also allows people to make announcements and suggestions and to discuss issues in the comments section. -

Note

+

Note

Note that the information in the DocTable may not always be up-to-date or accurate. When you assign yourself to documenting an @@ -160,7 +160,7 @@ this for documentation, not least of which is the single source nature of SGML. To contribute to the GDP you should learn to use DocBook. -

NOTE

+

NOTE

To get started writing for the GDP you do not need to rush out and learn DocBook - if you feel it is too much to handle for now, you can submit plain ASCII text to the @@ -206,25 +206,25 @@ your output document appearance subtly vary between the two DTD's. To install the GDP custom DTD with PNG image support by hand: -

There are many editors on Linux and UNIX systems available @@ -291,7 +291,7 @@ V1.1//EN"[]> the command $db2ps mydocument.sgml, after which you can print out or view the resulting .ps file. -

NOTE

+

NOTE

The html files you get will not look quite the same as the documentation distributed with GNOME unless you have the custom stylesheets installed on your machine. DocBook @@ -317,7 +317,7 @@ V1.1//EN"[]> <title>My Image</title> <screenshot> <screeninfo>Sample GNOME Display</screeninfo> - <graphic format="png" fileref="myfile" srccredit="me"> + <graphic format="png" fileref="myfile" srccredit="me"> </graphic> </screenshot> </figure> @@ -342,24 +342,24 @@ V1.1//EN"[]> There are many resources available to help you learn DocBook. The following resources on the web are useful for learning DocBook: -