Patch by James Vega
Make use of shellescape() and fnameescape() functions which better escape filenames than previous handmade calls to escape().
This commit is contained in:
parent
05a3e4e1f6
commit
9e7c686de5
@ -131,6 +131,10 @@ if (v:version < 700)
|
|||||||
echohl ErrorMsg | echo 'plugin gnupg.vim requires Vim version >= 7.0' | echohl None
|
echohl ErrorMsg | echo 'plugin gnupg.vim requires Vim version >= 7.0' | echohl None
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
if !(exists("*shellescape") && exists("*fnameescape"))
|
||||||
|
echohl ErrorMsg | echo 'plugin gnupg.vim requires Vim with the shellescape() and fnameescape() functions' | echohl None
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
" Section: Autocmd setup {{{1
|
" Section: Autocmd setup {{{1
|
||||||
|
|
||||||
@ -317,7 +321,7 @@ function s:GPGDecrypt()
|
|||||||
set bin
|
set bin
|
||||||
|
|
||||||
" get the filename of the current buffer
|
" get the filename of the current buffer
|
||||||
let filename = escape(expand("%:p"), '\"')
|
let filename = expand("%:p")
|
||||||
|
|
||||||
" clear GPGEncrypted, GPGRecipients and GPGOptions
|
" clear GPGEncrypted, GPGRecipients and GPGOptions
|
||||||
let b:GPGEncrypted = 0
|
let b:GPGEncrypted = 0
|
||||||
@ -325,7 +329,7 @@ function s:GPGDecrypt()
|
|||||||
let b:GPGOptions = []
|
let b:GPGOptions = []
|
||||||
|
|
||||||
" find the recipients of the file
|
" find the recipients of the file
|
||||||
let commandline = s:GPGCommand . " --verbose --decrypt --list-only --dry-run --batch --no-use-agent --logger-fd 1 \"" . filename . "\""
|
let commandline = s:GPGCommand . " --verbose --decrypt --list-only --dry-run --batch --no-use-agent --logger-fd 1 " . shellescape(filename)
|
||||||
call s:GPGDebug(3, "command: " . commandline)
|
call s:GPGDebug(3, "command: " . commandline)
|
||||||
let &shellredir = s:shellredir
|
let &shellredir = s:shellredir
|
||||||
let &shell = s:shell
|
let &shell = s:shell
|
||||||
@ -422,8 +426,8 @@ function s:GPGDecrypt()
|
|||||||
set nobin
|
set nobin
|
||||||
|
|
||||||
" call the autocommand for the file minus .gpg$
|
" call the autocommand for the file minus .gpg$
|
||||||
execute ":doautocmd BufReadPost " . escape(expand("%:r"), ' *?\"'."'")
|
execute ":doautocmd BufReadPost " . fnameescape(expand("%:r"))
|
||||||
call s:GPGDebug(2, "called autocommand for " . escape(expand("%:r"), ' *?\"'."'"))
|
call s:GPGDebug(2, "called autocommand for " . fnameescape(expand("%:r")))
|
||||||
|
|
||||||
" refresh screen
|
" refresh screen
|
||||||
redraw!
|
redraw!
|
||||||
@ -644,7 +648,7 @@ function s:GPGEditRecipients()
|
|||||||
" check if this buffer exists
|
" check if this buffer exists
|
||||||
if (!bufexists(editbuffername))
|
if (!bufexists(editbuffername))
|
||||||
" create scratch buffer
|
" create scratch buffer
|
||||||
execute 'silent! split ' . escape(editbuffername, ' *?\"'."'")
|
execute 'silent! split ' . fnameescape(editbuffername)
|
||||||
|
|
||||||
" add a autocommand to regenerate the recipients after a write
|
" add a autocommand to regenerate the recipients after a write
|
||||||
autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer()
|
autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer()
|
||||||
@ -654,7 +658,7 @@ function s:GPGEditRecipients()
|
|||||||
execute 'silent! ' . bufwinnr(editbuffername) . "wincmd w"
|
execute 'silent! ' . bufwinnr(editbuffername) . "wincmd w"
|
||||||
else
|
else
|
||||||
" split scratch buffer window
|
" split scratch buffer window
|
||||||
execute 'silent! sbuffer ' . escape(editbuffername, ' *?\"'."'")
|
execute 'silent! sbuffer ' . fnameescape(editbuffername)
|
||||||
|
|
||||||
" add a autocommand to regenerate the recipients after a write
|
" add a autocommand to regenerate the recipients after a write
|
||||||
autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer()
|
autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer()
|
||||||
@ -708,7 +712,7 @@ function s:GPGEditRecipients()
|
|||||||
let syntaxPattern = "\\(nonexxistinwordinthisbuffer"
|
let syntaxPattern = "\\(nonexxistinwordinthisbuffer"
|
||||||
for name in unknownrecipients
|
for name in unknownrecipients
|
||||||
let name = "!" . name
|
let name = "!" . name
|
||||||
let syntaxPattern = syntaxPattern . "\\|" . name
|
let syntaxPattern = syntaxPattern . "\\|" . fnameescape(name)
|
||||||
silent put =name
|
silent put =name
|
||||||
endfor
|
endfor
|
||||||
let syntaxPattern = syntaxPattern . "\\)"
|
let syntaxPattern = syntaxPattern . "\\)"
|
||||||
@ -866,7 +870,7 @@ function s:GPGEditOptions()
|
|||||||
" check if this buffer exists
|
" check if this buffer exists
|
||||||
if (!bufexists(editbuffername))
|
if (!bufexists(editbuffername))
|
||||||
" create scratch buffer
|
" create scratch buffer
|
||||||
execute 'silent! split ' . escape(editbuffername, ' *?\"'."'")
|
execute 'silent! split ' . fnameescape(editbuffername)
|
||||||
|
|
||||||
" add a autocommand to regenerate the options after a write
|
" add a autocommand to regenerate the options after a write
|
||||||
autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer()
|
autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer()
|
||||||
@ -876,7 +880,7 @@ function s:GPGEditOptions()
|
|||||||
execute 'silent! ' . bufwinnr(editbuffername) . "wincmd w"
|
execute 'silent! ' . bufwinnr(editbuffername) . "wincmd w"
|
||||||
else
|
else
|
||||||
" split scratch buffer window
|
" split scratch buffer window
|
||||||
execute 'silent! sbuffer ' . escape(editbuffername, ' *?\"'."'")
|
execute 'silent! sbuffer ' . fnameescape(editbuffername)
|
||||||
|
|
||||||
" add a autocommand to regenerate the options after a write
|
" add a autocommand to regenerate the options after a write
|
||||||
autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer()
|
autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer()
|
||||||
@ -1031,7 +1035,7 @@ function s:GPGNameToID(name)
|
|||||||
call s:GPGDebug(3, ">>>>>>>> Entering s:GPGNameToID()")
|
call s:GPGDebug(3, ">>>>>>>> Entering s:GPGNameToID()")
|
||||||
|
|
||||||
" ask gpg for the id for a name
|
" ask gpg for the id for a name
|
||||||
let commandline = s:GPGCommand . " --quiet --with-colons --fixed-list-mode --list-keys \"" . a:name . "\""
|
let commandline = s:GPGCommand . " --quiet --with-colons --fixed-list-mode --list-keys " . shellescape(a:name)
|
||||||
call s:GPGDebug(2, "command: ". commandline)
|
call s:GPGDebug(2, "command: ". commandline)
|
||||||
let &shellredir = s:shellredir
|
let &shellredir = s:shellredir
|
||||||
let &shell = s:shell
|
let &shell = s:shell
|
||||||
|
Loading…
x
Reference in New Issue
Block a user