mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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:
committed by
Ben Noordhuis
parent
179784e31e
commit
5ddf7f4200
@@ -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,
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user