Uploaded image for project: 'Santuario'
  1. Santuario
  2. SANTUARIO-140

Inclusive C14n doesn't always handle xml:space & xml:lang attributes correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Java 1.4.1
    • None
    • Java
    • Security Level: Public (Public issues, viewable by everyone)
    • None
    • Operating System: All
      Platform: All
    • 43230

    Description

      There is a very subtle bug in the inclusive C14N implementation that sometimes
      causes xml:space and xml:lang attributes to be handled incorrectly.

      Given the following input:

      <?xml version="1.0" encoding="UTF-8"?>
      <ietf:Xmllang xmlns:ietf="http://www.ietf.org"
      xmlns:w3c="http://www.w3.org">
      <ietf:e1 xml:lang="EN">
      <ietf:e11>
      <ietf:e111 />
      </ietf:e11>
      <ietf:e12 at="2">
      <ietf:e121 />
      </ietf:e12>
      </ietf:e1>
      <ietf:e2 >
      <ietf:e21 />
      </ietf:e2>
      </ietf:Xmllang>

      and an XPath expression of "ancestor-or-self::ietf:e1", the c14n representation
      should be:

      <ietf:e1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org"
      xml:lang="EN">
      <ietf:e11>
      <ietf:e111></ietf:e111>
      </ietf:e11>
      <ietf:e12 at="2">
      <ietf:e121></ietf:e121>
      </ietf:e12>
      </ietf:e1>

      However, the current behavior is:

      <ietf:e1 xmlns:ietf="http://www.ietf.org" xmlns:w3c="http://www.w3.org"
      xml:lang="EN">
      <ietf:e11>
      <ietf:e111></ietf:e111>
      </ietf:e11>
      <ietf:e12 at="2" xml:lang="EN">
      <ietf:e121></ietf:e121>
      </ietf:e12>
      </ietf:e1>

      Notice the xml:lang attribute in the "ietf:e12" element, which was incorrectly
      copied from the parent.

      The bug is in Canonicalizer20010315.java, in the XmlAttrStack.push() method:

      — Canonicalizer20010315.java (revision 548379)
      +++ Canonicalizer20010315.java (working copy)
      @@ -72,7 +72,7 @@
      if (currentLevel==-1)
      return;
      cur=null;

      • while (lastlevel>currentLevel) {
        + while (lastlevel>=currentLevel) {
        levels.remove(levels.size()-1);
        if (levels.size()==0) {
        lastlevel=0;

      The bug is that the implementation was taking the previous sibling's attribute
      context into account, which is not an ancestor, and thus the
      attributes were being inherited incorrectly in some cases. The simple
      change above fixes that.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sean.mullan@oracle.com sean.mullan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: