Escape Festschrift: getExec() needs to be escaped before being used.

This commit is contained in:
LCD 47 2014-02-06 16:50:27 +02:00
parent 4c2004d2e5
commit f5a45095e2
17 changed files with 31 additions and 22 deletions

View File

@ -75,7 +75,7 @@ function! g:SyntasticChecker.makeprgBuild(opts)
let setting = 'g:syntastic_' . self._filetype . '_' . self._name . '_' let setting = 'g:syntastic_' . self._filetype . '_' . self._name . '_'
let parts = [] let parts = []
call extend(parts, self._getOpt(a:opts, setting, 'exe', self.getExec())) call extend(parts, self._getOpt(a:opts, setting, 'exe', syntastic#util#shescape(self.getExec())))
call extend(parts, self._getOpt(a:opts, setting, 'args', '')) call extend(parts, self._getOpt(a:opts, setting, 'args', ''))
call extend(parts, self._getOpt(a:opts, setting, 'fname', syntastic#util#shexpand('%'))) call extend(parts, self._getOpt(a:opts, setting, 'fname', syntastic#util#shexpand('%')))
call extend(parts, self._getOpt(a:opts, setting, 'post_args', '')) call extend(parts, self._getOpt(a:opts, setting, 'post_args', ''))
@ -125,7 +125,7 @@ function! g:SyntasticChecker._shescape(opt)
if type(a:opt) == type('') && a:opt != '' if type(a:opt) == type('') && a:opt != ''
return [a:opt] return [a:opt]
elseif type(a:opt) == type([]) elseif type(a:opt) == type([])
return map(a:opt, 'syntastic#util#shescape(v:val)') return map(copy(a:opt), 'syntastic#util#shescape(v:val)')
endif endif
return [] return []

View File

@ -19,7 +19,7 @@ let s:save_cpo = &cpo
set cpo&vim set cpo&vim
function! SyntaxCheckers_c_make_GetLocList() dict function! SyntaxCheckers_c_make_GetLocList() dict
let makeprg = self.getExec() . ' -sk' let makeprg = syntastic#util#shescape(self.getExec()) . ' -sk'
let errorformat = let errorformat =
\ '%-G%f:%s:,' . \ '%-G%f:%s:,' .

View File

@ -24,7 +24,8 @@ set cpo&vim
function! SyntaxCheckers_coffee_coffee_IsAvailable() dict function! SyntaxCheckers_coffee_coffee_IsAvailable() dict
let exe = self.getExec() let exe = self.getExec()
return executable(exe) && return executable(exe) &&
\ syntastic#util#versionIsAtLeast(syntastic#util#getVersion(exe . ' --version 2>' . syntastic#util#DevNull()), [1,6,2]) \ syntastic#util#versionIsAtLeast(syntastic#util#getVersion(
\ syntastic#util#shescape(exe) . ' --version 2>' . syntastic#util#DevNull()), [1,6,2])
endfunction endfunction
function! SyntaxCheckers_coffee_coffee_GetLocList() dict function! SyntaxCheckers_coffee_coffee_GetLocList() dict

View File

@ -33,7 +33,8 @@ function! SyntaxCheckers_cuda_nvcc_GetLocList() dict
let arch_flag = '' let arch_flag = ''
endif endif
let makeprg = let makeprg =
\ self.getExec() . ' ' . arch_flag . ' --cuda -O0 -I . -Xcompiler -fsyntax-only ' . \ syntastic#util#shescape(self.getExec()) . ' ' . arch_flag .
\ ' --cuda -O0 -I . -Xcompiler -fsyntax-only ' .
\ syntastic#util#shexpand('%') . ' ' . syntastic#c#NullOutput() \ syntastic#util#shexpand('%') . ' ' . syntastic#c#NullOutput()
let errorformat = let errorformat =

View File

@ -19,7 +19,7 @@ let s:save_cpo = &cpo
set cpo&vim set cpo&vim
function! SyntaxCheckers_go_gotype_GetLocList() dict function! SyntaxCheckers_go_gotype_GetLocList() dict
let makeprg = self.getExec() . ' .' let makeprg = syntastic#util#shescape(self.getExec()) . ' .'
let errorformat = let errorformat =
\ '%f:%l:%c: %m,' . \ '%f:%l:%c: %m,' .

View File

@ -29,7 +29,8 @@ endfunction
function! SyntaxCheckers_haskell_ghc_mod_GetLocList() dict function! SyntaxCheckers_haskell_ghc_mod_GetLocList() dict
let makeprg = self.makeprgBuild({ let makeprg = self.makeprgBuild({
\ 'exe': self.getExec() . ' check' . (s:ghc_mod_new ? ' --boundary=""' : '') }) \ 'exe': syntastic#util#shescape(self.getExec()) . ' check' .
\ (s:ghc_mod_new ? ' --boundary=""' : '') })
let errorformat = let errorformat =
\ '%-G%\s%#,' . \ '%-G%\s%#,' .
@ -49,8 +50,9 @@ function! SyntaxCheckers_haskell_ghc_mod_GetLocList() dict
endfunction endfunction
function! s:GhcModNew(exe) function! s:GhcModNew(exe)
let exe = syntastic#util#shescape(a:exe)
try try
let ghc_mod_version = filter(split(system(a:exe), '\n'), 'v:val =~# ''\m^ghc-mod version''')[0] let ghc_mod_version = filter(split(system(exe), '\n'), 'v:val =~# ''\m^ghc-mod version''')[0]
let ret = syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(ghc_mod_version), [2, 1, 2]) let ret = syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(ghc_mod_version), [2, 1, 2])
catch /^Vim\%((\a\+)\)\=:E684/ catch /^Vim\%((\a\+)\)\=:E684/
call syntastic#log#error("checker haskell/ghc_mod: can't parse version string (abnormal termination?)") call syntastic#log#error("checker haskell/ghc_mod: can't parse version string (abnormal termination?)")

View File

@ -20,7 +20,7 @@ set cpo&vim
function! SyntaxCheckers_haskell_hdevtools_GetLocList() dict function! SyntaxCheckers_haskell_hdevtools_GetLocList() dict
let makeprg = self.makeprgBuild({ let makeprg = self.makeprgBuild({
\ 'exe': self.getExec() . ' check', \ 'exe': [self.getExec(), 'check'],
\ 'args': get(g:, 'hdevtools_options', '') }) \ 'args': get(g:, 'hdevtools_options', '') })
let errorformat= '\%-Z\ %#,'. let errorformat= '\%-Z\ %#,'.

View File

@ -65,7 +65,7 @@ endfunction
function! SyntaxCheckers_html_validator_GetLocList() dict function! SyntaxCheckers_html_validator_GetLocList() dict
let fname = syntastic#util#shexpand('%') let fname = syntastic#util#shexpand('%')
let makeprg = self.getExec() . ' -s --compressed -F out=gnu -F asciiquotes=yes' . let makeprg = syntastic#util#shescape(self.getExec()) . ' -s --compressed -F out=gnu -F asciiquotes=yes' .
\ (g:syntastic_html_validator_parser != '' ? ' -F parser=' . g:syntastic_html_validator_parser : '') . \ (g:syntastic_html_validator_parser != '' ? ' -F parser=' . g:syntastic_html_validator_parser : '') .
\ (g:syntastic_html_validator_nsfilter != '' ? ' -F nsfilter=' . g:syntastic_html_validator_nsfilter : '') . \ (g:syntastic_html_validator_nsfilter != '' ? ' -F nsfilter=' . g:syntastic_html_validator_nsfilter : '') .
\ ' -F doc=@' . fname . '\;type=text/html\;filename=' . fname . ' ' . g:syntastic_html_validator_api \ ' -F doc=@' . fname . '\;type=text/html\;filename=' . fname . ' ' . g:syntastic_html_validator_api

View File

@ -30,7 +30,7 @@ let s:save_cpo = &cpo
set cpo&vim set cpo&vim
function! SyntaxCheckers_html_w3_GetLocList() dict function! SyntaxCheckers_html_w3_GetLocList() dict
let makeprg = self.getExec() . ' -s -F output=json ' . let makeprg = syntastic#util#shescape(self.getExec()) . ' -s -F output=json ' .
\ '-F uploaded_file=@' . syntastic#util#shexpand('%:p') . '\;type=text/html ' . \ '-F uploaded_file=@' . syntastic#util#shexpand('%:p') . '\;type=text/html ' .
\ g:syntastic_html_w3_api \ g:syntastic_html_w3_api

View File

@ -19,7 +19,8 @@ let s:save_cpo = &cpo
set cpo&vim set cpo&vim
function! SyntaxCheckers_puppet_puppet_GetLocList() dict function! SyntaxCheckers_puppet_puppet_GetLocList() dict
let ver = syntastic#util#getVersion(self.getExec() . ' --version 2>' . syntastic#util#DevNull()) let ver = syntastic#util#getVersion(syntastic#util#shescape(self.getExec()) .
\ ' --version 2>' . syntastic#util#DevNull())
if syntastic#util#versionIsAtLeast(ver, [2,7,0]) if syntastic#util#versionIsAtLeast(ver, [2,7,0])
let args = 'parser validate --color=false' let args = 'parser validate --color=false'

View File

@ -59,10 +59,11 @@ function! SyntaxCheckers_python_pylint_GetLocList() dict
endfunction endfunction
function! s:PylintNew(exe) function! s:PylintNew(exe)
let exe = syntastic#util#shescape(a:exe)
try try
" On Windows the version is shown as "pylint-script.py 1.0.0". " On Windows the version is shown as "pylint-script.py 1.0.0".
" On Gentoo Linux it's "pylint-python2.7 0.28.0". Oh, joy. :) " On Gentoo Linux it's "pylint-python2.7 0.28.0". Oh, joy. :)
let pylint_version = filter(split(system(a:exe . ' --version'), '\m, \=\|\n'), 'v:val =~# ''\m^pylint\>''')[0] let pylint_version = filter(split(system(exe . ' --version'), '\m, \=\|\n'), 'v:val =~# ''\m^pylint\>''')[0]
let pylint_version = substitute(pylint_version, '\v^\S+\s+', '', '') let pylint_version = substitute(pylint_version, '\v^\S+\s+', '', '')
let ret = syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(pylint_version), [1]) let ret = syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(pylint_version), [1])
catch /^Vim\%((\a\+)\)\=:E684/ catch /^Vim\%((\a\+)\)\=:E684/

View File

@ -18,16 +18,17 @@ let g:loaded_syntastic_python_python_checker = 1
let s:save_cpo = &cpo let s:save_cpo = &cpo
set cpo&vim set cpo&vim
let s:compiler = syntastic#util#shescape(expand('<sfile>:p:h') . syntastic#util#Slash() . 'compile.py') let s:compiler = expand('<sfile>:p:h') . syntastic#util#Slash() . 'compile.py'
function! SyntaxCheckers_python_python_IsAvailable() dict function! SyntaxCheckers_python_python_IsAvailable() dict
let exe = self.getExec() let exe = self.getExec()
return executable(exe) && return executable(exe) &&
\ syntastic#util#versionIsAtLeast(syntastic#util#getVersion(exe . ' --version'), [2,6]) \ syntastic#util#versionIsAtLeast(syntastic#util#getVersion(
\ syntastic#util#shescape(exe) . ' --version'), [2, 6])
endfunction endfunction
function! SyntaxCheckers_python_python_GetLocList() dict function! SyntaxCheckers_python_python_GetLocList() dict
let makeprg = self.makeprgBuild({ 'exe': self.getExec() . ' ' . s:compiler }) let makeprg = self.makeprgBuild({ 'exe': [self.getExec(), s:compiler] })
let errorformat = '%E%f:%l:%c: %m' let errorformat = '%E%f:%l:%c: %m'

View File

@ -28,7 +28,7 @@ function! SyntaxCheckers_racket_code_ayatollah_IsAvailable() dict
endfunction endfunction
function! SyntaxCheckers_racket_code_ayatollah_GetLocList() dict function! SyntaxCheckers_racket_code_ayatollah_GetLocList() dict
let makeprg = self.makeprgBuild({ 'exe': self.getExec() . ' ' . s:script }) let makeprg = self.makeprgBuild({ 'exe': [self.getExec(), s:script] })
let errorformat = let errorformat =
\ ' %l:%v: %m,' . \ ' %l:%v: %m,' .

View File

@ -20,10 +20,10 @@ set cpo&vim
function! SyntaxCheckers_ruby_jruby_GetLocList() dict function! SyntaxCheckers_ruby_jruby_GetLocList() dict
if syntastic#util#isRunningWindows() if syntastic#util#isRunningWindows()
let exe = self.getExec() let exe = [self.getExec()]
let args = '-T1' let args = '-T1'
else else
let exe = 'RUBYOPT= ' . self.getExec() let exe = ['RUBYOPT=', self.getExec()]
let args = '' let args = ''
endif endif

View File

@ -19,7 +19,7 @@ set cpo&vim
function! SyntaxCheckers_ruby_macruby_GetLocList() dict function! SyntaxCheckers_ruby_macruby_GetLocList() dict
let makeprg = self.makeprgBuild({ let makeprg = self.makeprgBuild({
\ 'exe': 'RUBYOPT= ' . self.getExec(), \ 'exe': ['RUBYOPT=', self.getExec()],
\ 'args_after': '-W1 -c' }) \ 'args_after': '-W1 -c' })
let errorformat = let errorformat =

View File

@ -25,7 +25,8 @@ function! SyntaxCheckers_ruby_rubocop_IsAvailable() dict
let exe = self.getExec() let exe = self.getExec()
return return
\ executable(exe) && \ executable(exe) &&
\ syntastic#util#versionIsAtLeast(syntastic#util#getVersion(exe . ' --version'), [0,9,0]) \ syntastic#util#versionIsAtLeast(syntastic#util#getVersion(
\ syntastic#util#shescape(exe) . ' --version'), [0, 9, 0])
endfunction endfunction
function! SyntaxCheckers_ruby_rubocop_GetLocList() dict function! SyntaxCheckers_ruby_rubocop_GetLocList() dict

View File

@ -24,7 +24,8 @@ set cpo&vim
function! SyntaxCheckers_yaml_jsyaml_GetLocList() dict function! SyntaxCheckers_yaml_jsyaml_GetLocList() dict
if !exists('s:js_yaml_new') if !exists('s:js_yaml_new')
let s:js_yaml_new = let s:js_yaml_new =
\ syntastic#util#versionIsAtLeast(syntastic#util#getVersion(self.getExec() . ' --version'), [2]) \ syntastic#util#versionIsAtLeast(syntastic#util#getVersion(
\ syntastic#util#shescape(self.getExec()) . ' --version'), [2])
endif endif
let makeprg = self.makeprgBuild({ 'args_after': (s:js_yaml_new ? '' : '--compact') }) let makeprg = self.makeprgBuild({ 'args_after': (s:js_yaml_new ? '' : '--compact') })