From 9fcaca996bef6ab7a3b5f74e2f699c034327b518 Mon Sep 17 00:00:00 2001 From: Scott Santucci Date: Sun, 5 Mar 2017 02:05:48 -0500 Subject: [PATCH 1/5] fix #2300 --- lib/reporters/html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporters/html.js b/lib/reporters/html.js index 3e755d2d63..78508ac53b 100644 --- a/lib/reporters/html.js +++ b/lib/reporters/html.js @@ -222,7 +222,7 @@ function makeUrl (s) { // Remove previous grep query parameter if present if (search) { - search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?'); + search = search.replace(/[?&]f?grep=[^&\s]*/g, '').replace(/^&/, '?'); } return window.location.pathname + (search ? search + '&' : '?') + 'grep=' + encodeURIComponent(escapeRe(s)); From a2f855cc458f46287b845eb74a20987d6c012b3a Mon Sep 17 00:00:00 2001 From: ScottFreeCode Date: Sun, 5 Mar 2017 02:11:42 -0500 Subject: [PATCH 2/5] Fix HTML escaping --- lib/reporters/html.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/reporters/html.js b/lib/reporters/html.js index 78508ac53b..77347be384 100644 --- a/lib/reporters/html.js +++ b/lib/reporters/html.js @@ -117,7 +117,7 @@ function HTML (runner) { // suite var url = self.suiteURL(suite); - var el = fragment('
  • %s

  • ', url, escape(suite.title)); + var el = fragment('
  • %e

  • ', url, suite.title); // container stack[0].appendChild(el); @@ -136,7 +136,7 @@ function HTML (runner) { runner.on('pass', function (test) { var url = self.testURL(test); var markup = '
  • %e%ems ' + - '

  • '; + ''; var el = fragment(markup, test.speed, test.title, test.duration, url); self.addCodeToggle(el, test.body); appendToStack(el); @@ -270,7 +270,7 @@ HTML.prototype.addCodeToggle = function (el, contents) { * @param {string} msg */ function error (msg) { - document.body.appendChild(fragment('
    %s
    ', msg)); + document.body.appendChild(fragment('
    %e
    ', msg)); } /** From f23154befebfafc1471b8bd8baa5db86acd037c1 Mon Sep 17 00:00:00 2001 From: ScottFreeCode Date: Sun, 5 Mar 2017 02:24:49 -0500 Subject: [PATCH 3/5] Fix #2285 --- lib/reporters/html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporters/html.js b/lib/reporters/html.js index 77347be384..9e9e914a93 100644 --- a/lib/reporters/html.js +++ b/lib/reporters/html.js @@ -225,7 +225,7 @@ function makeUrl (s) { search = search.replace(/[?&]f?grep=[^&\s]*/g, '').replace(/^&/, '?'); } - return window.location.pathname + (search ? search + '&' : '?') + 'grep=' + encodeURIComponent(escapeRe(s)); + return window.location.href.replace(new RegExp("^(.*?" + escapeRe(window.location.pathname) + ").*$"), "$1") + (search ? search + '&' : '?') + 'grep=' + encodeURIComponent(escapeRe(s)); } /** From c1b69502dd61444ca850364b079bd69a1db77228 Mon Sep 17 00:00:00 2001 From: ScottFreeCode Date: Sun, 5 Mar 2017 02:16:30 -0500 Subject: [PATCH 4/5] Fix HTML half of #2298 --- lib/reporters/html.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/reporters/html.js b/lib/reporters/html.js index 9e9e914a93..abf07d7984 100644 --- a/lib/reporters/html.js +++ b/lib/reporters/html.js @@ -214,10 +214,14 @@ function HTML (runner) { /** * Makes a URL, preserving querystring ("search") parameters. * - * @param {string} s + * @param {string} s (will be escaped) + * @param {string} prefix (will not be escaped, precedes s, defaults to empty string) + * @param {string} suffix (will not be escaped, follows s, defaults to empty string) * @return {string} A new URL. */ -function makeUrl (s) { +function makeUrl (s, prefix, suffix) { + if (prefix == null) { prefix = ''; } + if (suffix == null) { suffix = ''; } var search = window.location.search; // Remove previous grep query parameter if present @@ -225,7 +229,7 @@ function makeUrl (s) { search = search.replace(/[?&]f?grep=[^&\s]*/g, '').replace(/^&/, '?'); } - return window.location.href.replace(new RegExp("^(.*?" + escapeRe(window.location.pathname) + ").*$"), "$1") + (search ? search + '&' : '?') + 'grep=' + encodeURIComponent(escapeRe(s)); + return window.location.href.replace(new RegExp("^(.*?" + escapeRe(window.location.pathname) + ").*$"), "$1") + (search ? search + '&' : '?') + 'grep=' + encodeURIComponent(prefix + escapeRe(s) + suffix); } /** @@ -234,7 +238,7 @@ function makeUrl (s) { * @param {Object} [suite] */ HTML.prototype.suiteURL = function (suite) { - return makeUrl(suite.fullTitle()); + return makeUrl(suite.fullTitle(), '^'); }; /** @@ -243,7 +247,7 @@ HTML.prototype.suiteURL = function (suite) { * @param {Object} [test] */ HTML.prototype.testURL = function (test) { - return makeUrl(test.fullTitle()); + return makeUrl(test.fullTitle(), '^', '$'); }; /** From ce1415e96c1c8ea7253cd4c63a3ad537337006b5 Mon Sep 17 00:00:00 2001 From: Scott Santucci Date: Sun, 5 Mar 2017 18:57:19 -0500 Subject: [PATCH 5/5] Fix linting I can't believe I forgot the right string quote character. Javascript, man... --- lib/reporters/html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporters/html.js b/lib/reporters/html.js index abf07d7984..5184609586 100644 --- a/lib/reporters/html.js +++ b/lib/reporters/html.js @@ -229,7 +229,7 @@ function makeUrl (s, prefix, suffix) { search = search.replace(/[?&]f?grep=[^&\s]*/g, '').replace(/^&/, '?'); } - return window.location.href.replace(new RegExp("^(.*?" + escapeRe(window.location.pathname) + ").*$"), "$1") + (search ? search + '&' : '?') + 'grep=' + encodeURIComponent(prefix + escapeRe(s) + suffix); + return window.location.href.replace(new RegExp('^(.*?' + escapeRe(window.location.pathname) + ').*$'), '$1') + (search ? search + '&' : '?') + 'grep=' + encodeURIComponent(prefix + escapeRe(s) + suffix); } /**