Skip to content

Commit

Permalink
Escape the URL passed to RegEx (web-platform-tests#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk authored and jgraham committed May 20, 2016
1 parent 3383edb commit a9517c8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion testharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,9 @@ policies and contribution forms [3].

// Create a pattern to match stack frames originating within testharness.js. These include the
// script URL, followed by the line/col (e.g., '/resources/testharness.js:120:21').
var re = new RegExp((get_script_url() || "\\btestharness.js") + ":\\d+:\\d+");
// Escape the URL per http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
// in case it contains RegExp characters.
var re = new RegExp((get_script_url().replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') || "\\btestharness.js") + ":\\d+:\\d+");

// Some browsers include a preamble that specifies the type of the error object. Skip this by
// advancing until we find the first stack frame originating from testharness.js.
Expand Down

0 comments on commit a9517c8

Please sign in to comment.