You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kp...@apache.org on 2013/10/02 23:24:33 UTC

svn commit: r1528631 - /tomcat/trunk/webapps/docs/tomcat-docs.xsl

Author: kpreisser
Date: Wed Oct  2 21:24:33 2013
New Revision: 1528631

URL: http://svn.apache.org/r1528631
Log:
New try: Use the correct subdir for loading the project.xml into the $project variable, and use $project variable instead of <project> tree that is placed by "&project;" entity.

Modified:
    tomcat/trunk/webapps/docs/tomcat-docs.xsl

Modified: tomcat/trunk/webapps/docs/tomcat-docs.xsl
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/tomcat-docs.xsl?rev=1528631&r1=1528630&r2=1528631&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/tomcat-docs.xsl (original)
+++ tomcat/trunk/webapps/docs/tomcat-docs.xsl Wed Oct  2 21:24:33 2013
@@ -53,9 +53,10 @@
   <xsl:variable name="commentslink"><xsl:value-of select="$relative-path"/>/comments.html</xsl:variable>
 
   <!-- Process an entire document into an HTML page -->
+  <xsl:variable name="project-xml-filename"><xsl:value-of select="$subdir"/>project.xml</xsl:variable>
   <xsl:template match="document">
   <xsl:variable name="project"
-              select="document('project.xml')/project"/>
+              select="document($project-xml-filename)/project"/>
 <html lang="en">
 <head>
   <!-- Note: XLST seems to always output a
@@ -73,7 +74,7 @@
   </xsl:variable>
   <link href="{$css-src}" rel="stylesheet" type="text/css"/>
 
-  <title><xsl:value-of select="project/title"/> (<xsl:value-of select="$version"/>) - <xsl:value-of select="properties/title"/></title>
+  <title><xsl:value-of select="$project/title"/> (<xsl:value-of select="$version"/>) - <xsl:value-of select="properties/title"/></title>
   <xsl:for-each select="properties/author">
     <xsl:variable name="name">
       <xsl:value-of select="."/>
@@ -141,12 +142,12 @@
   <header><div id="header">
     <div>
       <div>
-        <xsl:if test="project/logo">
+        <xsl:if test="$project/logo">
           <xsl:variable name="src">
             <xsl:value-of select="$relative-path"/><xsl:value-of select="$home-logo"/>
           </xsl:variable>
           <div class="logo noPrint">
-            <a href="{project/@href}"><img alt="Tomcat Home" src="{$src}"/></a>
+            <a href="{$project/@href}"><img alt="Tomcat Home" src="{$src}"/></a>
           </div>
         </xsl:if>
 
@@ -174,7 +175,7 @@
         <div>
           <!-- Navigation -->
           <nav>
-            <xsl:apply-templates select="project/body/menu"/>
+            <xsl:apply-templates select="$project/body/menu"/>
           </nav>
         </div>
       </div>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


RE: svn commit: r1528631 - /tomcat/trunk/webapps/docs/tomcat-docs.xsl

Posted by Konstantin Preißer <kp...@apache.org>.
Hi Konstantin,

> -----Original Message-----
> From: Konstantin Kolinko [mailto:knst.kolinko@gmail.com]
> Sent: Thursday, October 3, 2013 1:36 PM


> The file mentioned in external entity declaration is loaded (via
> entity resolver) and its text is inserted as is in the specified
> place,
> 
> 
> My impression from the last time that I checked this feature, two or
> more years ago, is that it is security limitation in those particular
> browsers.
> 
> (Especially in IE.  I think that older Firefox versions did process
> the entity and did show the menu, but I do not see this behaviour with
> the current version. Currently both IE 10 and Firefox 24 behave the
> same for Tomcat 7 docs).
> 
> There were security issues in processing of external entities in XML
> in old versions of IE. If I remember correctly, it allowed to read
> some arbitrary files.
> 
> (I thought that it was an old story, but quick search finds recent
> issues, announced in September 2013,
> http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-3159
> http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-3160

Thank you for the explanation. It makes sense that this is disabled because of security concerns.
E.g. I was able to make IE8 reading an arbitrary local file and report the contents with JavaScript, when opening a local .xml file (but not when opening a http://... URL).


> It is nice that you found the $project as the way to implement this.
> Though I do no see any use of the menu except showing the actual
> layout of the page. The menu itself is useless, as
> 
> a) it has links to *.html documents, not *.xml ones.
> b) none other xml documents have stylesheet directive
> 
> 
> I do not care much of the menus. I do care that the file is readable
> when I browse the changelog locally (via file:// protocol) as a
> preview before committing a change. Your $project recipe does work
> here and it is good.
> 
> By the way, just for information, a similar security issue:
> I once tried to apply the same XSLT trick in Tomcat Native
> miscelaneous/changelog.xml as
> <?xml-stylesheet type="text/xsl" href="../style.xsl"?>
> 
> That It did not work when browsing locally.  The problem is that
> browsers refuse to load stylesheet from parent directory
> ("../style.xsl") because of security concerns.
> 
> Best regards,
> Konstantin Kolinko
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org


Regards,
Konstantin Preißer


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1528631 - /tomcat/trunk/webapps/docs/tomcat-docs.xsl

Posted by Konstantin Kolinko <kn...@gmail.com>.
2013/10/3 Konstantin Preißer <kp...@apache.org>:
> Hi,
>
>> -----Original Message-----
>> From: kpreisser@apache.org [mailto:kpreisser@apache.org]
>> Sent: Wednesday, October 2, 2013 11:25 PM
>
>> -            <xsl:apply-templates select="project/body/menu"/>
>> +            <xsl:apply-templates select="$project/body/menu"/>
>
> The previous version seemed to use the <project> tree that is loaded from project.xml by the "&project;" entity that is placed on top of the <document>:
>
> <document url="monitoring.html">
>
>   &project;
>
>   <properties>
>     <title>Monitoring and Managing Tomcat</title>
>   </properties>
> [...]
>
> Which is declared in the doctype:
>
> <!DOCTYPE document [
>   <!ENTITY project SYSTEM "project.xml">
> ]>
>
> However, Firefox and IE didn't seem to load the content from "project.xml", so when viewing changelog.xml (http://svn.apache.org/repos/asf/tomcat/trunk/webapps/docs/changelog.xml) the LHS menu, project title etc. were not visible.
>
> When using the $project variable (which is filled with the tree from project.xml by XSLT via document() function), then everything works.
>
> Does somebody know why that &project; entity did not work in such browsers?
>
> I do not have such detailed knowledge of XML - how is this entity supposed to work? E.g. when I open a file like monitoring.xml in Tomcat docs then the XML tree shown by the browser does not contain a <project> element.

The file mentioned in external entity declaration is loaded (via
entity resolver) and its text is inserted as is in the specified
place,


My impression from the last time that I checked this feature, two or
more years ago, is that it is security limitation in those particular
browsers.

(Especially in IE.  I think that older Firefox versions did process
the entity and did show the menu, but I do not see this behaviour with
the current version. Currently both IE 10 and Firefox 24 behave the
same for Tomcat 7 docs).

There were security issues in processing of external entities in XML
in old versions of IE. If I remember correctly, it allowed to read
some arbitrary files.

(I thought that it was an old story, but quick search finds recent
issues, announced in September 2013,
http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-3159
http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-3160


It is nice that you found the $project as the way to implement this.
Though I do no see any use of the menu except showing the actual
layout of the page. The menu itself is useless, as

a) it has links to *.html documents, not *.xml ones.
b) none other xml documents have stylesheet directive


I do not care much of the menus. I do care that the file is readable
when I browse the changelog locally (via file:// protocol) as a
preview before committing a change. Your $project recipe does work
here and it is good.

By the way, just for information, a similar security issue:
I once tried to apply the same XSLT trick in Tomcat Native
miscelaneous/changelog.xml as
<?xml-stylesheet type="text/xsl" href="../style.xsl"?>

That It did not work when browsing locally.  The problem is that
browsers refuse to load stylesheet from parent directory
("../style.xsl") because of security concerns.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


RE: svn commit: r1528631 - /tomcat/trunk/webapps/docs/tomcat-docs.xsl

Posted by Konstantin Preißer <kp...@apache.org>.
Hi,

> -----Original Message-----
> From: kpreisser@apache.org [mailto:kpreisser@apache.org]
> Sent: Wednesday, October 2, 2013 11:25 PM

> -            <xsl:apply-templates select="project/body/menu"/>
> +            <xsl:apply-templates select="$project/body/menu"/>

The previous version seemed to use the <project> tree that is loaded from project.xml by the "&project;" entity that is placed on top of the <document>:

<document url="monitoring.html">

  &project;

  <properties>
    <title>Monitoring and Managing Tomcat</title>
  </properties>
[...]

Which is declared in the doctype:

<!DOCTYPE document [
  <!ENTITY project SYSTEM "project.xml">
]>

However, Firefox and IE didn't seem to load the content from "project.xml", so when viewing changelog.xml (http://svn.apache.org/repos/asf/tomcat/trunk/webapps/docs/changelog.xml) the LHS menu, project title etc. were not visible.

When using the $project variable (which is filled with the tree from project.xml by XSLT via document() function), then everything works.

Does somebody know why that &project; entity did not work in such browsers? I do not have such detailed knowledge of XML - how is this entity supposed to work? E.g. when I open a file like monitoring.xml in Tomcat docs then the XML tree shown by the browser does not contain a <project> element.


Regards,
Konstantin Preißer


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org