Incorrect DigiDocService PHP sample application

Earlier versions of DigiDocService PHP sample application (probably distributed before 2009), specifically the Digidoc.class.php distributed with the application, contain an error. This error causes the creation of faulty DigiDoc containers whose datafiles are missing the xmlns attribute in <DataFile> element . 

In this case you should start using the newest version of Digidoc.class.php (found in sample application source code) as soon as possible.  Verification of these faulty containers can be complicated due to noncompliance with the specification. 

According to DigiDoc specification description every initial datafile in DigiDoc container has to include xmlns attribute (SignedDoc namespace http://www.sk.ee/DigiDoc/v1.3.0#) in <DataFile> element.

How to verify if your system contains the problematic Digidoc.class.php

If the function setDigiDocFormatAndVersion() does not set DigiDoc container format and version in else{} branch according to the following example then you have the problematic Digidoc.class.php version:

function setDigiDocFormatAndVersion($xml='') {
  if ($xml=='')
    $xml=$this->xml;
  if ($xml) {
    preg_match("'(\<SignedDoc.*\/SignedDoc\>)'Us", $xml, $match);
    $content = $match[1];
    preg_match("'format=\"(.*)\"'Us", $content, $match);
    $this->format = $match[1];
    preg_match("'version=\"(.*)\"'Us", $content, $match);
    $this->version = $match[1];
   } else {
    $this->format = "";
    $this->version = "";
  }
}

Correct version should use this method:

function setDigiDocFormatAndVersion($xml='') {
  if ($xml=='')
    $xml=$this->xml;
  if ($xml) {
    preg_match("'(\<SignedDoc.*\/SignedDoc\>)'Us", $xml, $match);
    $content = $match[1];
    preg_match("'format=\"(.*)\"'Us", $content, $match);
    $this->format = $match[1];
    preg_match("'version=\"(.*)\"'Us", $content, $match);
    $this->version = $match[1];
  } else {
    $this->format = "DIGIDOC-XML";
    $this->version = "1.3";
  }
}


ASK FOR HELP

If you didn't find an answer to your question, send it to our team.



  • See instructions
  • Please estimate your ability to use the computer, so that we can provide you with the best guidance

         

  • Verification failed

How can we improve the article and be more helpful?
Send Close