debugger: fix bug in breakpoint regex escaping

Fix a bug in setBreakpoint() where not all regex characters are escaped
when constructing scriptRegEx for V8.
This commit is contained in:
Miroslav Bajtoš
2013-04-29 14:09:26 +02:00
committed by Ben Noordhuis
parent 179784e31e
commit 5ddf7f4200
2 changed files with 11 additions and 3 deletions

View File

@@ -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,

View File

@@ -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));