☕️ Classic, reliable, trusted test framework for Node.js and the browser
Fixed html entity escaping in doc reporter code
Tj Holowaychuk39362ed3bb11
diff --git a/lib/reporters/doc.js b/lib/reporters/doc.jsindex 7e83e984..8175e433 100644--- a/lib/reporters/doc.js+++ b/lib/reporters/doc.js@@ -3,7 +3,8 @@* Module dependencies.*/-var Base = require('./base');+var Base = require('./base')+ , utils = require('../utils');/*** Expose `Doc`.@@ -49,7 +50,7 @@ function Doc(runner) {runner.on('pass', function(test){console.log('%s <dt>%s</dt>', indent(), test.title);- var code = clean(test.fn.toString());+ var code = utils.escape(clean(test.fn.toString()));console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);});diff --git a/lib/utils.js b/lib/utils.jsnew file mode 100644index 00000000..35570bce--- /dev/null+++ b/lib/utils.js@@ -0,0 +1,16 @@++/**+ * Escape special characters in the given string of html.+ *+ * @param {String} html+ * @return {String}+ * @api private+ */++exports.escape = function(html) {+ return String(html)+ .replace(/&/g, '&')+ .replace(/"/g, '"')+ .replace(/</g, '<')+ .replace(/>/g, '>');+};\ No newline at end of file