Browse Source

debugger: fix bug in breakpoint regex escaping

Fix a bug in setBreakpoint() where not all regex characters are escaped
when constructing scriptRegEx for V8.
v0.11.2-release
Miroslav Bajtoš 12 years ago
committed by Ben Noordhuis
parent
commit
5ddf7f4200
  1. 4
      lib/_debugger.js
  2. 10
      test/simple/test-debugger-repl-break-in-module.js

4
lib/_debugger.js

@ -1398,8 +1398,8 @@ Interface.prototype.setBreakpoint = function(script, line,
};
} else {
this.print('Warning: script \'' + script + '\' was not loaded yet.');
var normalizedPath = script.replace('([/.?*])', '\\$1');
var scriptPathRegex = '^(.*[\\/\\\\])?' + normalizedPath + '$';
var escapedPath = script.replace(/([/\\.?*()^${}|[\]])/g, '\\$1');
var scriptPathRegex = '^(.*[\\/\\\\])?' + escapedPath + '$';
req = {
type: 'scriptRegExp',
target: scriptPathRegex,

10
test/simple/test-debugger-repl-break-in-module.js

@ -31,6 +31,12 @@ repl.addTest('sb("mod.js", 23)', [
/1/, /2/, /3/, /4/, /5/, /6/
]);
// Check escaping of regex characters
repl.addTest('sb(")^$*+?}{|][(.js\\\\", 1)', [
/Warning: script '[^']+' was not loaded yet\./,
/1/, /2/, /3/, /4/, /5/, /6/
]);
// continue - the breakpoint should be triggered
repl.addTest('c', [
/break in .*[\\\/]mod\.js:23/,
@ -47,7 +53,9 @@ repl.addTest('restart', [].concat(
repl.handshakeLines,
[
/Restoring breakpoint mod.js:23/,
/Warning: script 'mod\.js' was not loaded yet\./
/Warning: script 'mod\.js' was not loaded yet\./,
/Restoring breakpoint \).*:\d+/,
/Warning: script '\)[^']*' was not loaded yet\./
],
repl.initialBreakLines));

Loading…
Cancel
Save