Skip to content

Commit

Permalink
Encode failure message when appending replay URL
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjduffy committed Dec 1, 2023
1 parent 617e466 commit ade24e2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/cypress/src/junit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ function addReplayLinkProperty(node: INode, replayUrls: string[]) {
}
}

function escapeForXml(content: string) {
return content.replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;");
}

function appendReplayUrlsToFailureNodes(node: INode, replayUrls: string[]) {
try {
const failures = findDescendentsByTagName(node, "failure");
Expand All @@ -120,8 +124,11 @@ function appendReplayUrlsToFailureNodes(node: INode, replayUrls: string[]) {
return;
}

failure.children[0] +=
"\n\n View in Replay\n" + replayUrls.map(url => ` * ${url}`).join("\n");
const output = `${failure.children[0]}\n\nView in Replay\n${replayUrls
.map(url => ` * ${url}`)
.join("\n")}`;

failure.children[0] = escapeForXml(output);
});
} catch (e) {
debug("Failed to add replay url to failure output: %s", e);
Expand Down

0 comments on commit ade24e2

Please sign in to comment.