Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape __dirname before generating regexp #191

Merged
merged 1 commit into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/ticks-to-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Copy link
Contributor

@goto-bus-stop goto-bus-stop Oct 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't escape windows-path\preload, but I don't think that's a problem… escape(join()) would make sure the entire thing is escaped, regardless

Suggested change
const preloadDirRx = RegExp(join(escape(__dirname), 'preload'))
const preloadDirRx = RegExp(escape(join(__dirname, 'preload')))

Copy link
Contributor

@goto-bus-stop goto-bus-stop Oct 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually escaping before joining does introduce more backslashes which may be a problem for unicodey windows paths or network drives? I'm not really familiar with them, just know that there's a bunch of \\?\\whatever going on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

escaping after joining does not work. I tried that first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's unintuitive. Alright 👍

const internalModuleRegExp = /^.?(?:\(anonymous\)|internalBinding|NativeModule[^ ]*) [^/\\][a-zA-Z0-9_/\\-]+\.js:\d+:\d+$/
const nodeBootstrapRegExp = / internal\/bootstrap.+\.js:\d+:\d+$/

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down