From f5a45095e2742808baf20e34ade852bfd1416990 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Thu, 6 Feb 2014 16:50:27 +0200 Subject: [PATCH] Escape Festschrift: getExec() needs to be escaped before being used. --- plugin/syntastic/checker.vim | 4 ++-- syntax_checkers/c/make.vim | 2 +- syntax_checkers/coffee/coffee.vim | 3 ++- syntax_checkers/cuda/nvcc.vim | 3 ++- syntax_checkers/go/gotype.vim | 2 +- syntax_checkers/haskell/ghc-mod.vim | 6 ++++-- syntax_checkers/haskell/hdevtools.vim | 2 +- syntax_checkers/html/validator.vim | 2 +- syntax_checkers/html/w3.vim | 2 +- syntax_checkers/puppet/puppet.vim | 3 ++- syntax_checkers/python/pylint.vim | 3 ++- syntax_checkers/python/python.vim | 7 ++++--- syntax_checkers/racket/code-ayatollah.vim | 2 +- syntax_checkers/ruby/jruby.vim | 4 ++-- syntax_checkers/ruby/macruby.vim | 2 +- syntax_checkers/ruby/rubocop.vim | 3 ++- syntax_checkers/yaml/jsyaml.vim | 3 ++- 17 files changed, 31 insertions(+), 22 deletions(-) diff --git a/plugin/syntastic/checker.vim b/plugin/syntastic/checker.vim index 68cf08dc..24c7d64a 100644 --- a/plugin/syntastic/checker.vim +++ b/plugin/syntastic/checker.vim @@ -75,7 +75,7 @@ function! g:SyntasticChecker.makeprgBuild(opts) let setting = 'g:syntastic_' . self._filetype . '_' . self._name . '_' 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, 'fname', syntastic#util#shexpand('%'))) 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 != '' return [a:opt] 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 return [] diff --git a/syntax_checkers/c/make.vim b/syntax_checkers/c/make.vim index c019da5a..530154f1 100644 --- a/syntax_checkers/c/make.vim +++ b/syntax_checkers/c/make.vim @@ -19,7 +19,7 @@ let s:save_cpo = &cpo set cpo&vim function! SyntaxCheckers_c_make_GetLocList() dict - let makeprg = self.getExec() . ' -sk' + let makeprg = syntastic#util#shescape(self.getExec()) . ' -sk' let errorformat = \ '%-G%f:%s:,' . diff --git a/syntax_checkers/coffee/coffee.vim b/syntax_checkers/coffee/coffee.vim index d42a96a6..28f1f685 100644 --- a/syntax_checkers/coffee/coffee.vim +++ b/syntax_checkers/coffee/coffee.vim @@ -24,7 +24,8 @@ set cpo&vim function! SyntaxCheckers_coffee_coffee_IsAvailable() dict let exe = self.getExec() 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 function! SyntaxCheckers_coffee_coffee_GetLocList() dict diff --git a/syntax_checkers/cuda/nvcc.vim b/syntax_checkers/cuda/nvcc.vim index 1494982e..43b8fc3b 100644 --- a/syntax_checkers/cuda/nvcc.vim +++ b/syntax_checkers/cuda/nvcc.vim @@ -33,7 +33,8 @@ function! SyntaxCheckers_cuda_nvcc_GetLocList() dict let arch_flag = '' endif 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() let errorformat = diff --git a/syntax_checkers/go/gotype.vim b/syntax_checkers/go/gotype.vim index ae3b6247..c762e8d7 100644 --- a/syntax_checkers/go/gotype.vim +++ b/syntax_checkers/go/gotype.vim @@ -19,7 +19,7 @@ let s:save_cpo = &cpo set cpo&vim function! SyntaxCheckers_go_gotype_GetLocList() dict - let makeprg = self.getExec() . ' .' + let makeprg = syntastic#util#shescape(self.getExec()) . ' .' let errorformat = \ '%f:%l:%c: %m,' . diff --git a/syntax_checkers/haskell/ghc-mod.vim b/syntax_checkers/haskell/ghc-mod.vim index 51737034..0daab046 100644 --- a/syntax_checkers/haskell/ghc-mod.vim +++ b/syntax_checkers/haskell/ghc-mod.vim @@ -29,7 +29,8 @@ endfunction function! SyntaxCheckers_haskell_ghc_mod_GetLocList() dict 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 = \ '%-G%\s%#,' . @@ -49,8 +50,9 @@ function! SyntaxCheckers_haskell_ghc_mod_GetLocList() dict endfunction function! s:GhcModNew(exe) + let exe = syntastic#util#shescape(a:exe) 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]) catch /^Vim\%((\a\+)\)\=:E684/ call syntastic#log#error("checker haskell/ghc_mod: can't parse version string (abnormal termination?)") diff --git a/syntax_checkers/haskell/hdevtools.vim b/syntax_checkers/haskell/hdevtools.vim index 0175e046..03d0db73 100644 --- a/syntax_checkers/haskell/hdevtools.vim +++ b/syntax_checkers/haskell/hdevtools.vim @@ -20,7 +20,7 @@ set cpo&vim function! SyntaxCheckers_haskell_hdevtools_GetLocList() dict let makeprg = self.makeprgBuild({ - \ 'exe': self.getExec() . ' check', + \ 'exe': [self.getExec(), 'check'], \ 'args': get(g:, 'hdevtools_options', '') }) let errorformat= '\%-Z\ %#,'. diff --git a/syntax_checkers/html/validator.vim b/syntax_checkers/html/validator.vim index 250d2c34..64a0ee6f 100644 --- a/syntax_checkers/html/validator.vim +++ b/syntax_checkers/html/validator.vim @@ -65,7 +65,7 @@ endfunction function! SyntaxCheckers_html_validator_GetLocList() dict 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_nsfilter != '' ? ' -F nsfilter=' . g:syntastic_html_validator_nsfilter : '') . \ ' -F doc=@' . fname . '\;type=text/html\;filename=' . fname . ' ' . g:syntastic_html_validator_api diff --git a/syntax_checkers/html/w3.vim b/syntax_checkers/html/w3.vim index cdb8a633..d5667f08 100644 --- a/syntax_checkers/html/w3.vim +++ b/syntax_checkers/html/w3.vim @@ -30,7 +30,7 @@ let s:save_cpo = &cpo set cpo&vim 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 ' . \ g:syntastic_html_w3_api diff --git a/syntax_checkers/puppet/puppet.vim b/syntax_checkers/puppet/puppet.vim index 5e2250b6..49200a2d 100644 --- a/syntax_checkers/puppet/puppet.vim +++ b/syntax_checkers/puppet/puppet.vim @@ -19,7 +19,8 @@ let s:save_cpo = &cpo set cpo&vim 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]) let args = 'parser validate --color=false' diff --git a/syntax_checkers/python/pylint.vim b/syntax_checkers/python/pylint.vim index e43fc037..aaa6f9b8 100644 --- a/syntax_checkers/python/pylint.vim +++ b/syntax_checkers/python/pylint.vim @@ -59,10 +59,11 @@ function! SyntaxCheckers_python_pylint_GetLocList() dict endfunction function! s:PylintNew(exe) + let exe = syntastic#util#shescape(a:exe) try " 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. :) - 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 ret = syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(pylint_version), [1]) catch /^Vim\%((\a\+)\)\=:E684/ diff --git a/syntax_checkers/python/python.vim b/syntax_checkers/python/python.vim index 3ff74f54..92fe297e 100644 --- a/syntax_checkers/python/python.vim +++ b/syntax_checkers/python/python.vim @@ -18,16 +18,17 @@ let g:loaded_syntastic_python_python_checker = 1 let s:save_cpo = &cpo set cpo&vim -let s:compiler = syntastic#util#shescape(expand(':p:h') . syntastic#util#Slash() . 'compile.py') +let s:compiler = expand(':p:h') . syntastic#util#Slash() . 'compile.py' function! SyntaxCheckers_python_python_IsAvailable() dict let exe = self.getExec() 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 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' diff --git a/syntax_checkers/racket/code-ayatollah.vim b/syntax_checkers/racket/code-ayatollah.vim index 96ecf396..f8002a72 100644 --- a/syntax_checkers/racket/code-ayatollah.vim +++ b/syntax_checkers/racket/code-ayatollah.vim @@ -28,7 +28,7 @@ function! SyntaxCheckers_racket_code_ayatollah_IsAvailable() dict endfunction 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 = \ ' %l:%v: %m,' . diff --git a/syntax_checkers/ruby/jruby.vim b/syntax_checkers/ruby/jruby.vim index aba10955..4689c883 100644 --- a/syntax_checkers/ruby/jruby.vim +++ b/syntax_checkers/ruby/jruby.vim @@ -20,10 +20,10 @@ set cpo&vim function! SyntaxCheckers_ruby_jruby_GetLocList() dict if syntastic#util#isRunningWindows() - let exe = self.getExec() + let exe = [self.getExec()] let args = '-T1' else - let exe = 'RUBYOPT= ' . self.getExec() + let exe = ['RUBYOPT=', self.getExec()] let args = '' endif diff --git a/syntax_checkers/ruby/macruby.vim b/syntax_checkers/ruby/macruby.vim index 60e05dc7..b0f5f108 100644 --- a/syntax_checkers/ruby/macruby.vim +++ b/syntax_checkers/ruby/macruby.vim @@ -19,7 +19,7 @@ set cpo&vim function! SyntaxCheckers_ruby_macruby_GetLocList() dict let makeprg = self.makeprgBuild({ - \ 'exe': 'RUBYOPT= ' . self.getExec(), + \ 'exe': ['RUBYOPT=', self.getExec()], \ 'args_after': '-W1 -c' }) let errorformat = diff --git a/syntax_checkers/ruby/rubocop.vim b/syntax_checkers/ruby/rubocop.vim index d16b69e4..7b31d197 100644 --- a/syntax_checkers/ruby/rubocop.vim +++ b/syntax_checkers/ruby/rubocop.vim @@ -25,7 +25,8 @@ function! SyntaxCheckers_ruby_rubocop_IsAvailable() dict let exe = self.getExec() return \ 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 function! SyntaxCheckers_ruby_rubocop_GetLocList() dict diff --git a/syntax_checkers/yaml/jsyaml.vim b/syntax_checkers/yaml/jsyaml.vim index 2e2fe9e4..6595606b 100644 --- a/syntax_checkers/yaml/jsyaml.vim +++ b/syntax_checkers/yaml/jsyaml.vim @@ -24,7 +24,8 @@ set cpo&vim function! SyntaxCheckers_yaml_jsyaml_GetLocList() dict if !exists('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 let makeprg = self.makeprgBuild({ 'args_after': (s:js_yaml_new ? '' : '--compact') })