Skip to content

Commit

Permalink
Merge pull request #180 from MediaArea/NO-JUNK-IN-FIXEDSIZE-MATROSKA
Browse files Browse the repository at this point in the history
add test for NO-JUNK-IN-FIXEDSIZE-MATROSKA
  • Loading branch information
JeromeMartinez committed May 15, 2017
2 parents 6d39e20 + 4eb7818 commit bad7cea
Showing 1 changed file with 98 additions and 0 deletions.
Expand Up @@ -116,6 +116,20 @@
<xsl:with-param name="element" select="mmt:MicroMediaTrace/mmt:b//mmt:b[mmt:b[1][@n='Header']/mmt:d[@n='Name']]"/>
</xsl:call-template>
<!-- /EBML-ELEMENT-VALID-PARENT -->
<!-- NO-JUNK-IN-FIXEDSIZE-MATROSKA -->
<xsl:call-template name="element_contains_no_junk">
<xsl:with-param name="icid">NO-JUNK-IN-FIXEDSIZE-MATROSKA</xsl:with-param>
<xsl:with-param name="version">1</xsl:with-param>
<xsl:with-param name="element" select="mmt:MicroMediaTrace//mmt:b[@n!='Segment'][@n!='Cluster'][mmt:b[1][@n='Header']/mmt:d[@n='Name']][not(mmt:d)]"/>
</xsl:call-template>
<!-- /NO-JUNK-IN-FIXEDSIZE-MATROSKA -->
<!-- EBML-ELEM-UNKNOWN-SIZE -->
<xsl:call-template name="size_is_not_unlimited">
<xsl:with-param name="icid">EBML-ELEM-UNKNOWN-SIZE</xsl:with-param>
<xsl:with-param name="version">1</xsl:with-param>
<xsl:with-param name="element" select="mmt:MicroMediaTrace//mmt:b[@n!='Segment'][@n!='Cluster'][mmt:b[1][@n='Header']/mmt:d[@n='Name']][mmt:b[1][@n='Header']/mmt:d[@n='Size']='Unlimited']"/>
</xsl:call-template>
<!-- /EBML-ELEM-UNKNOWN-SIZE -->
<!-- EBML-ELEMENT-NONMULTIPLES -->
<xsl:call-template name="element_does_not_repeat_in_parent">
<xsl:with-param name="icid">EBML-ELEMENT-NONMULTIPLES</xsl:with-param>
Expand Down Expand Up @@ -719,6 +733,44 @@
</xsl:call-template>
</xsl:template>

<xsl:template name="element_contains_no_junk">
<xsl:param name="icid"/>
<xsl:param name="version"/>
<xsl:param name="element"/>
<xsl:call-template name="check">
<xsl:with-param name="icid" select="$icid"/>
<xsl:with-param name="version" select="$version"/>
<xsl:with-param name="test">
<xsl:for-each select="$element">
<xsl:variable name="ElementName">
<xsl:value-of select="@n"/>
</xsl:variable>
<xsl:if test="mmt:b[@n='Junk']">
<xsl:variable name="offset">
<xsl:value-of select="@o"/>
</xsl:variable>
<xsl:variable name="values">
<xsl:call-template name="EBMLElementValue">
<xsl:with-param name="ElementName" select="$ElementName"/>
</xsl:call-template>
</xsl:variable>
<test>
<xsl:attribute name="outcome">fail</xsl:attribute>
<xsl:attribute name="reason">
<xsl:value-of select="$ElementName"/>
<xsl:text> contains </xsl:text>
<xsl:value-of select="mmt:b[@n='Junk']/@s"/>
<xsl:text> bytes of junk data at offset </xsl:text>
<xsl:value-of select="mmt:b[@n='Junk']/@o"/>
<xsl:text>.</xsl:text>
</xsl:attribute>
<xsl:copy-of select="$values"/>
</test>
</xsl:if>
</xsl:for-each>
</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template name="element_at_correct_size">
<xsl:param name="icid"/>
Expand Down Expand Up @@ -1161,6 +1213,52 @@
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="size_is_not_unlimited">
<xsl:param name="icid"/>
<xsl:param name="version"/>
<xsl:param name="element"/>
<xsl:call-template name="check">
<xsl:with-param name="icid" select="$icid"/>
<xsl:with-param name="version" select="$version"/>
<xsl:with-param name="test">
<xsl:for-each select="$element">
<xsl:variable name="ElementName">
<xsl:value-of select="@n"/>
</xsl:variable>
<xsl:variable name="element_size">
<xsl:value-of select="mmt:b[1][@n='Header']/mmt:d[@n='Size']"/>
</xsl:variable>
<xsl:variable name="values">
<xsl:for-each select="parent::mmt:b">
<xsl:call-template name="EBMLElementValue">
<xsl:with-param name="ElementName" select="$ElementName"/>
</xsl:call-template>
</xsl:for-each>
</xsl:variable>
<xsl:choose>
<xsl:when test="$element_size != 'Unlimited'">
<test>
<xsl:attribute name="outcome">pass</xsl:attribute>
<xsl:attribute name="ya">
<xsl:value-of select="mmt:b[1][@n='Header']/mmt:d[@n='Size']"/>
</xsl:attribute>
<xsl:copy-of select="$values"/>
</test>
</xsl:when>
<xsl:otherwise>
<test>
<xsl:attribute name="outcome">fail</xsl:attribute>
<xsl:attribute name="reason">
<xsl:text>An element uses an unknown size where it isn't allowed.</xsl:text>
</xsl:attribute>
<xsl:copy-of select="$values"/>
</test>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="x_is_in_list">
<xsl:param name="icid"/>
<xsl:param name="version"/>
Expand Down

0 comments on commit bad7cea

Please sign in to comment.