Skip to content

Commit

Permalink
Add a check for long mdui:Logo elements; initial threshold of 40000
Browse files Browse the repository at this point in the history
  • Loading branch information
iay committed Mar 23, 2020
1 parent f7ae6ed commit 876b708
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
52 changes: 52 additions & 0 deletions mdx/_rules/check_mdui_logo_length.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
check_mdui_logo_length.xsl
Checking ruleset to generate warnings for mdui:Logo elements with
lengths longer than a provided threshold.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui"
xmlns:mdxURL="xalan://uk.ac.sdss.xalan.md.URLchecker"
xmlns:set="http://exslt.org/sets"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:oasis:names:tc:SAML:2.0:metadata">

<!--
Common support functions.
-->
<xsl:import href="check_framework.xsl"/>

<!--
maxLength
This parameter determines the maximum allowable mdui:Logo length
before we issue a warning.
-->
<xsl:param name="maxLength"/>

<!--
Match mdui:Logo elements whose string length is greater than the
threshold value; issue a warning for them.
Template match expressions can't include parameter references, so
match all mdui:Logo elements then dig in with a conditional.
-->
<xsl:template match="mdui:Logo">
<xsl:if test="string-length(.) > $maxLength">
<xsl:call-template name="warning">
<xsl:with-param name="m">
<xsl:text>mdui:Logo has long contents: </xsl:text>
<xsl:value-of select="string-length(.)"/>
<xsl:text> > </xsl:text>
<xsl:value-of select="$maxLength"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>

</xsl:stylesheet>
16 changes: 16 additions & 0 deletions mdx/validation-beans.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,21 @@
<bean id="check_mdui_xslt" parent="mda.XSLValidationStage"
p:XSLResource="classpath:_rules/check_mdui.xsl"/>

<!--
check_mdui_logo_length
Add a warning for mdui:Logo elements longer than some
threshold.
-->
<bean id="check_mdui_logo_length" parent="mda.XSLValidationStage"
p:XSLResource="classpath:_rules/check_mdui_logo_length.xsl">
<property name="transformParameters">
<map>
<entry key="maxLength" value="${mdui.logo.length.warn:40000}"/>
</map>
</property>
</bean>

<!--
check_mdui
Expand All @@ -230,6 +245,7 @@
<list>
<ref bean="check_mdui_iphint"/>
<ref bean="check_mdui_xslt"/>
<ref bean="check_mdui_logo_length"/>
</list>
</property>
</bean>
Expand Down

0 comments on commit 876b708

Please sign in to comment.