diff --git a/lib/reporters/browser.js b/lib/reporters/browser.js index 9836c90c9..d43213fe3 100644 --- a/lib/reporters/browser.js +++ b/lib/reporters/browser.js @@ -54,6 +54,12 @@ exports.run = function (modules, options) { return el; }; + function HTMLEscape(str) { + return str.replace(/&/g, '&') + .replace(//g, '>'); + }; + var header = getOrCreate('h1', 'nodeunit-header'); var banner = getOrCreate('h2', 'nodeunit-banner'); var userAgent = getOrCreate('h2', 'nodeunit-userAgent'); @@ -92,7 +98,7 @@ exports.run = function (modules, options) { var a = assertions[i]; if (a.failed()) { li.innerHTML = (a.message || a.method || 'no message') + - '
' + (a.error.stack || a.error) + '
'; + '
' + HTMLEscape(a.error.stack || a.error) + '
'; li.className = 'fail'; } else {