I have a system that allows a user to provide their own XSLT to apply to some data that has been extracted, as a means of determining how that data should be presented. However, if the user includes XSLT equivalent code:
<xsl:template match="/">
<xsl:element name="data">
<xsl:apply-templates select="." />
</xsl:element>
</xsl:template>
this causes .NET to infinitely recursively try to process it and generate an error. I need to catch this before it works, when the data that has been retrieved from time to time takes quite a lot of time, and the data is lost when this happens.
Is there any way to do this? I know that it is theoretically possible to identify any occurrences of xsl: apply-templates with "." in the select attribute, but this is not the only way infinite recursion can happen, I need a way to capture it all.
source
share