Microsoft KB Archive/284453

= BUG: XML Context Method Can Traverse Out of Xsl:template Element =

Article ID: 284453

Article Last Modified on 6/4/2003

-

APPLIES TO


 * Microsoft XML Parser 2.0
 * Microsoft XML Parser 2.5
 * Microsoft XML Parser 2.6
 * Microsoft XML Core Services 4.0
 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer (Programming) 5.01 SP1
 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q284453



SYMPTOMS
When you use the context method of the &quot;http://www.w3.org/TR/WD-xsl&quot; namespace, it is possible to use a negative value for the index parameter from an xsl:template element, effectively navigating the context out of the template. It should not be possible to do this because the template can be called from more than one location, which means that the value of context(-n) changes depending on how the template is called.



RESOLUTION
This problem is discussed here for reference purposes only, because the context method has been superceded by the current method of the &quot;http://www.w3.org/1999/XSL/Transform&quot; namespace.

Use the current method and its corresponding namespace instead of the context method.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
  Insert the following code into a new text document, and save the file as repro.xml:     Insert the following text into another new document, and save the file as repro.xsl in the same location as the XML file you just created: 

    </BODY> </HTML> </xsl:template>

<xsl:template match=&quot;Student&quot;> <LI><xsl:value-of select = &quot;@name&quot; /></LI><BR/> <xsl:if test=&quot;context[$not$ end]&quot;><BR/></xsl:if>

<B>This should not work!!!</B><BR/> <LI><xsl:value-of select = &quot;@name&quot; /></LI><BR/> <xsl:if test=&quot;context(-2)[$not$ end]&quot;><BR/></xsl:if> </xsl:template>

</xsl:stylesheet> </li> Browse to repro.xml by using Internet Explorer (IE). The template should not be able to query the negative context, but it does so successfully.</li></ol>

Keywords: kbbug kbpending kbmsxmlnosweep KB284453

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.