Skip to content

Question about ApplyTransformers #75

@ghost

Description

I have doubts about this code:

xmldsigjs/src/signed_xml.ts

Lines 544 to 573 in 71e66d3

protected ApplyTransforms(transforms: XmlTransforms, input: Element): any {
let output: any = null;
transforms.Sort((a, b) => {
const c14nTransforms = [Transforms.XmlDsigC14NTransform, XmlDsigC14NWithCommentsTransform,
Transforms.XmlDsigExcC14NTransform, XmlDsigExcC14NWithCommentsTransform];
if (c14nTransforms.some((t) => a instanceof t)) {
return 1;
}
if (c14nTransforms.some((t) => b instanceof t)) {
return -1;
}
return 0;
}).ForEach((transform) => {
transform.LoadInnerXml(input);
if (transform instanceof Transforms.XmlDsigXPathTransform) {
transform.GetOutput();
} else {
output = transform.GetOutput();
}
});
// Apply C14N transform if Reference has only one transform EnvelopedSignature
if (transforms.Count === 1 && transforms.Item(0) instanceof Transforms.XmlDsigEnvelopedSignatureTransform) {
const c14n = new Transforms.XmlDsigC14NTransform();
c14n.LoadInnerXml(input);
output = c14n.GetOutput();
}
return output;
}

  1. Why there is "dummy" GetOutput call at 560?
  2. Why every transformer load initial xml (line 585) instead of the result returned by the predecessor? It look like only last transformer works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions