Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/SignatureXAdES_B.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ Signatures::Signatures(istream &data, ASiContainer *container)
properties.schema_location(URI_ID_DSIG, File::fullPathUrl(xsdPath + "/xmldsig-core-schema.xsd"));
properties.schema_location(ASIC_NAMESPACE, File::fullPathUrl(xsdPath + "/en_31916201v010101.xsd"));
properties.schema_location(OPENDOCUMENT_NAMESPACE, File::fullPathUrl(xsdPath + "/OpenDocument_dsig.xsd"));
parseDOM(data, properties.schema_location());
copy << data.rdbuf();

parseDOM(copy, properties.schema_location());

try
{
Expand Down Expand Up @@ -208,12 +210,20 @@ void Signatures::reloadDOM()
// Save to file an parse it again, to make XML Canonicalization work
// correctly as expected by the Canonical XML 1.0 specification.
// Hope, the next Canonical XMl specification fixes the white spaces preserving "bug".
stringstream ofs;
save(ofs);
parseDOM(ofs);
copy.str({});
copy.clear();
saveXML(copy);
parseDOM(copy);
}

void Signatures::save(ostream &os) const
{
if(copy.str().empty())
return saveXML(os);
os << copy.str();
}

void Signatures::saveXML(ostream &os) const
{
try
{
Expand Down
3 changes: 3 additions & 0 deletions src/SignatureXAdES_B.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <map>
#include <memory>
#include <sstream>

namespace digidoc
{
Expand Down Expand Up @@ -57,8 +58,10 @@ namespace digidoc

private:
void parseDOM(std::istream &data, const std::string &schema_location = {});
void saveXML(std::ostream &os) const;

std::unique_ptr<xercesc::DOMDocument> doc;
std::stringstream copy;
};

class SignatureXAdES_B : public Signature
Expand Down