☕️ Classic, reliable, trusted test framework for Node.js and the browser
Use safer XML escaping
Jan Krems45c870dd2081
diff --git a/lib/utils.js b/lib/utils.jsindex 43e28bc4..c40c97cd 100644--- a/lib/utils.js+++ b/lib/utils.js@@ -36,7 +36,7 @@ exports.inherits = require('util').inherits;* @return {string}*/exports.escape = function (html) {- return he.encode(String(html), { useNamedReferences: true });+ return he.encode(String(html), { useNamedReferences: false });};/**diff --git a/test/reporters/doc.spec.js b/test/reporters/doc.spec.jsindex 2e0d1e02..060c61c1 100644--- a/test/reporters/doc.spec.js+++ b/test/reporters/doc.spec.js@@ -43,7 +43,7 @@ describe('Doc reporter', function () {root: false,title: unescapedTitle};- expectedTitle = '<div>' + expectedTitle + '</div>';+ expectedTitle = '<div>' + expectedTitle + '</div>';runner.on = function (event, callback) {if (event === 'suite') {callback(suite);@@ -142,8 +142,8 @@ describe('Doc reporter', function () {test.title = unescapedTitle;test.body = unescapedBody;- var expectedEscapedTitle = '<div>' + expectedTitle + '</div>';- var expectedEscapedBody = '<div>' + expectedBody + '</div>';+ var expectedEscapedTitle = '<div>' + expectedTitle + '</div>';+ var expectedEscapedBody = '<div>' + expectedBody + '</div>';runner.on = function (event, callback) {if (event === 'pass') {callback(test);@@ -192,9 +192,9 @@ describe('Doc reporter', function () {test.title = unescapedTitle;test.body = unescapedBody;- var expectedEscapedTitle = '<div>' + expectedTitle + '</div>';- var expectedEscapedBody = '<div>' + expectedBody + '</div>';- var expectedEscapedError = '<div>' + expectedError + '</div>';+ var expectedEscapedTitle = '<div>' + expectedTitle + '</div>';+ var expectedEscapedBody = '<div>' + expectedBody + '</div>';+ var expectedEscapedError = '<div>' + expectedError + '</div>';runner.on = function (event, callback) {if (event === 'fail') {callback(test, unescapedError);diff --git a/test/unit/utils.spec.js b/test/unit/utils.spec.jsindex 078d05e5..4ef87c60 100644--- a/test/unit/utils.spec.js+++ b/test/unit/utils.spec.js@@ -627,13 +627,13 @@ describe('lib/utils', function () {describe('escape', function () {it('replaces the usual xml suspects', function () {- expect(utils.escape('<a<bc<d<')).to.be('<a<bc<d<');- expect(utils.escape('>a>bc>d>')).to.be('>a>bc>d>');- expect(utils.escape('"a"bc"d"')).to.be('"a"bc"d"');- expect(utils.escape('<>"&')).to.be('<>"&');+ expect(utils.escape('<a<bc<d<')).to.be('<a<bc<d<');+ expect(utils.escape('>a>bc>d>')).to.be('>a>bc>d>');+ expect(utils.escape('"a"bc"d"')).to.be('"a"bc"d"');+ expect(utils.escape('<>"&')).to.be('<>"&');- expect(utils.escape('&a&bc&d&')).to.be('&a&bc&d&');- expect(utils.escape('&<')).to.be('&amp;&lt;');+ expect(utils.escape('&a&bc&d&')).to.be('&a&bc&d&');+ expect(utils.escape('&<')).to.be('&amp;&lt;');});it('replaces invalid xml characters', function () {