-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add missing calls to the shellescape() function #1099
Changes from all commits
56cfbcf
eb21a47
1273b65
5c36bbf
1f76824
c4d49a2
3382e7d
d4ea4fa
965ca82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -388,44 +388,67 @@ endfunction | |
|
||
" FUNCTION: NERDTreeQuickLook() {{{1 | ||
function! NERDTreeQuickLook() | ||
let treenode = g:NERDTreeFileNode.GetSelected() | ||
if treenode !=# {} | ||
call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lifecrisis , do you have a way to test this? These single quotes are thwarting my attempts to do the command injection in the old code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of these will allow injection when operating on a file that looks like...
Opening this file on Linux with func! g:Foo()
return "'; touch FOOBAR ; echo '"
endfunc
call system("xdg-open '" . g:Foo() . "' &") This problem seems like it would never happen, but you can do some funky things in the terminal... like concealing characters that actually are contained in the path using terminal escape codes. It's definitely better to use |
||
let l:node = g:NERDTreeFileNode.GetSelected() | ||
|
||
if empty(l:node) | ||
return | ||
endif | ||
|
||
call system('qlmanage -p 2>/dev/null ' . shellescape(l:node.path.str())) | ||
endfunction | ||
|
||
" FUNCTION: NERDTreeRevealInFinder() {{{1 | ||
function! NERDTreeRevealInFinder() | ||
let treenode = g:NERDTreeFileNode.GetSelected() | ||
if treenode !=# {} | ||
call system("open -R '" . treenode.path.str() . "'") | ||
let l:node = g:NERDTreeFileNode.GetSelected() | ||
|
||
if empty(l:node) | ||
return | ||
endif | ||
|
||
call system('open -R ' . shellescape(l:node.path.str())) | ||
endfunction | ||
|
||
" FUNCTION: NERDTreeExecuteFile() {{{1 | ||
function! NERDTreeExecuteFile() | ||
let treenode = g:NERDTreeFileNode.GetSelected() | ||
if treenode !=# {} | ||
call system("open '" . treenode.path.str() . "'") | ||
let l:node = g:NERDTreeFileNode.GetSelected() | ||
|
||
if empty(l:node) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you following a certain pattern here, instead of if !empty()
do the thing
endif There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I always prefer early returns. They seem cleaner to me; i.e., I think they're simpler and read better. Strictly speaking, though, we should probably be using |
||
return | ||
endif | ||
|
||
call system('open ' . shellescape(l:node.path.str())) | ||
endfunction | ||
|
||
" FUNCTION: NERDTreeRevealFileLinux() {{{1 | ||
function! NERDTreeRevealFileLinux() | ||
let treenode = g:NERDTreeFileNode.GetSelected() | ||
let parentnode = treenode.parent | ||
if parentnode !=# {} | ||
call system("xdg-open '" . parentnode.path.str() . "' &") | ||
let l:node = g:NERDTreeFileNode.GetSelected() | ||
|
||
if empty(l:node) | ||
return | ||
endif | ||
|
||
" Handle the edge case of "/", which has no parent. | ||
if l:node.path.str() ==# '/' | ||
call system('xdg-open /') | ||
return | ||
endif | ||
|
||
if empty(l:node.parent) | ||
return | ||
endif | ||
|
||
call system('xdg-open ' . shellescape(l:node.parent.path.str())) | ||
endfunction | ||
|
||
" FUNCTION: NERDTreeExecuteFileLinux() {{{1 | ||
function! NERDTreeExecuteFileLinux() | ||
let treenode = g:NERDTreeFileNode.GetSelected() | ||
if treenode !=# {} | ||
call system("xdg-open '" . treenode.path.str() . "' &") | ||
let l:node = g:NERDTreeFileNode.GetSelected() | ||
|
||
if empty(l:node) | ||
return | ||
endif | ||
|
||
call system('xdg-open ' . shellescape(l:node.path.str())) | ||
endfunction | ||
|
||
" vim: set sw=4 sts=4 et fdm=marker: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
shellescape()
take into account the OS and the&shellslash
setting?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know.
Because this is security related, though, I would recommend using it and only reverting it if people complain.