Skip to content

Commit

Permalink
Fixed: escape strings in HTML reporter. Closes #164
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Dec 19, 2011
1 parent 3a16faf commit f059da6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/reporters/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

var Base = require('./base')
, utils = require('../utils')
, Progress = require('../browser/progress');
, Progress = require('../browser/progress')
, escape = utils.escape;

/**
* Expose `Doc`.
Expand Down Expand Up @@ -94,20 +95,18 @@ function HTML(runner) {

// test
if (test.passed) {
var el = $('<div class="test pass"><h2>' + test.title + '</h2></div>')
var el = $('<div class="test pass"><h2>' + escape(test.title) + '</h2></div>')
} else if (test.pending) {
var el = $('<div class="test pass pending"><h2>' + test.title + '</h2></div>')
var el = $('<div class="test pass pending"><h2>' + escape(test.title) + '</h2></div>')
} else {
var el = $('<div class="test fail"><h2>' + test.title + '</h2></div>');
var el = $('<div class="test fail"><h2>' + escape(test.title) + '</h2></div>');
var str = test.err.stack || test.err;

// <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
// check for the result of the stringifying.
if ('[object Error]' == str) {
str = test.err.message;
}
if ('[object Error]' == str) str = test.err.message;

var err = $('<pre class="error">' + str + '</pre>');
var err = $('<pre class="error">' + escape(str) + '</pre>');
el.append(err);
}

Expand All @@ -121,7 +120,7 @@ function HTML(runner) {
// code
// TODO: defer
if (!test.pending) {
var code = utils.escape(clean(test.fn.toString()));
var code = escape(clean(test.fn.toString()));
var pre = $('<pre><code>' + code + '</code></pre>');
pre.appendTo(el).hide();
}
Expand Down

0 comments on commit f059da6

Please sign in to comment.