From 9727c01f842522d488a4c22cc409fa8131663fba Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Fri, 19 Oct 2018 15:22:14 +0200 Subject: [PATCH] Escape __dirname before generating regexp --- lib/ticks-to-tree.js | 3 ++- package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ticks-to-tree.js b/lib/ticks-to-tree.js index deb7392..7559ccf 100644 --- a/lib/ticks-to-tree.js +++ b/lib/ticks-to-tree.js @@ -4,8 +4,9 @@ const { spawnSync } = require('child_process') const { join } = require('path') const debug = require('debug')('0x: ticks-to-tree') const assert = require('assert') +const escape = require('escape-string-regexp') -const preloadDirRx = RegExp(join(__dirname, 'preload')) +const preloadDirRx = RegExp(join(escape(__dirname), 'preload')) const internalModuleRegExp = /^.?(?:\(anonymous\)|internalBinding|NativeModule[^ ]*) [^/\\][a-zA-Z0-9_/\\-]+\.js:\d+:\d+$/ const nodeBootstrapRegExp = / internal\/bootstrap.+\.js:\d+:\d+$/ diff --git a/package.json b/package.json index e518208..434e5d2 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "debug": "^4.0.1", "end-of-stream": "^1.1.0", "env-string": "^1.0.0", + "escape-string-regexp": "^1.0.5", "execspawn": "^1.0.1", "has-unicode": "^2.0.1", "hsl-to-rgb-for-reals": "^1.1.0",