mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 11:53:48 -05:00
Improve "g:NERDTreeQuickLook()"
The following improvements were made... - Use variable sigils - Shorten a local variable name - Prefer an early return over testing for a negative - Switch to single quotes - Call "shellescape()" to pass a command argument [IMPORTANT!] The final change is a critical fix for the security and reliability of this function (see ":h system()"). Similar fixes for the other functions in this script will follow.
This commit is contained in:
@@ -388,10 +388,13 @@ endfunction
|
|||||||
|
|
||||||
" FUNCTION: NERDTreeQuickLook() {{{1
|
" FUNCTION: NERDTreeQuickLook() {{{1
|
||||||
function! NERDTreeQuickLook()
|
function! NERDTreeQuickLook()
|
||||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||||
if treenode !=# {}
|
|
||||||
call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'")
|
if empty(l:node)
|
||||||
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
call system('qlmanage -p 2>/dev/null ' . shellescape(l:node.path.str()))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: NERDTreeRevealInFinder() {{{1
|
" FUNCTION: NERDTreeRevealInFinder() {{{1
|
||||||
@@ -428,4 +431,3 @@ function! NERDTreeExecuteFileLinux()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" vim: set sw=4 sts=4 et fdm=marker:
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user