Skip to content

Commit

Permalink
Using a less agressive escape function to fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kræn Hansen committed Jul 19, 2017
1 parent 967e3b8 commit 561db46
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/junit_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@
pad(d.getMinutes()) + ':' +
pad(d.getSeconds());
}
function escapeControlChars(str) {
// Remove control character from Jasmine default output
return str.replace(/[\x1b]/g, "");
}
function escapeInvalidXmlChars(str) {
return str.replace(/\&/g, "&")
const escaped = str.replace(/\&/g, "&")
.replace(/</g, "&lt;")
.replace(/\>/g, "&gt;")
.replace(/\"/g, "&quot;")
.replace(/\'/g, "&apos;")
.replace(/[\x1b]/g, ""); //Remove control character from Jasmine default output
.replace(/\'/g, "&apos;");
return escapeControlChars(escaped);
}
function getQualifiedFilename(path, filename, separator) {
if (path && path.substr(-1) !== separator && filename.substr(0) !== separator) {
Expand Down Expand Up @@ -443,7 +447,7 @@
testCaseBody += '\n <failure type="' + (failure.matcherName || "exception") + '"';
testCaseBody += ' message="' + trim(escapeInvalidXmlChars(failure.message))+ '"';
testCaseBody += '>';
testCaseBody += '<![CDATA[' + trim(escapeInvalidXmlChars(failure.stack || failure.message)) + ']]>';
testCaseBody += '<![CDATA[' + trim(escapeControlChars(failure.stack || failure.message)) + ']]>';
testCaseBody += '\n </failure>';
}
}
Expand Down

0 comments on commit 561db46

Please sign in to comment.