Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Stack trace is not HTML escaped in browser #191

Open
wants to merge 1 commit into from

1 participant

@uhoreg

When a test fails, the stack trace is not HTML escaped when displayed in the browser, which means that if you are testing the equality of two strings that contain HTML elements, you will not be able to see the HTML elements. This patch fixes this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 31, 2013
  1. @uhoreg

    HTML escape stack trace

    uhoreg authored
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/reporters/browser.js
View
8 lib/reporters/browser.js
@@ -54,6 +54,12 @@ exports.run = function (modules, options) {
return el;
};
+ function HTMLEscape(str) {
+ return str.replace(/&/g, '&')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;');
+ };
+
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') +
- '<pre>' + (a.error.stack || a.error) + '</pre>';
+ '<pre>' + HTMLEscape(a.error.stack || a.error) + '</pre>';
li.className = 'fail';
}
else {
Something went wrong with that request. Please try again.