mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-27 13:22:17 +08:00
#540 Fix shell escaping pretty much everywhere
This commit is contained in:
@@ -5,7 +5,7 @@ let g:ale_asm_gcc_options = get(g:, 'ale_asm_gcc_options', '-Wall')
|
||||
|
||||
function! ale_linters#asm#gcc#GetCommand(buffer) abort
|
||||
return 'gcc -x assembler -fsyntax-only '
|
||||
\ . '-iquote ' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
\ . '-iquote ' . shellescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
\ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -'
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ function! ale_linters#c#clang#GetCommand(buffer) abort
|
||||
" -iquote with the directory the file is in makes #include work for
|
||||
" headers in the same directory.
|
||||
return 'clang -S -x c -fsyntax-only '
|
||||
\ . '-iquote ' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
\ . '-iquote ' . shellescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
\ . ' ' . ale#Var(a:buffer, 'c_clang_options') . ' -'
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ function! ale_linters#c#gcc#GetCommand(buffer) abort
|
||||
" -iquote with the directory the file is in makes #include work for
|
||||
" headers in the same directory.
|
||||
return 'gcc -S -x c -fsyntax-only '
|
||||
\ . '-iquote ' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
\ . '-iquote ' . shellescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
\ . ' ' . ale#Var(a:buffer, 'c_gcc_options') . ' -'
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ function! ale_linters#cpp#clang#GetCommand(buffer) abort
|
||||
" -iquote with the directory the file is in makes #include work for
|
||||
" headers in the same directory.
|
||||
return 'clang++ -S -x c++ -fsyntax-only '
|
||||
\ . '-iquote ' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
\ . '-iquote ' . shellescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
\ . ' ' . ale#Var(a:buffer, 'cpp_clang_options') . ' -'
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ function! ale_linters#cpp#gcc#GetCommand(buffer) abort
|
||||
" -iquote with the directory the file is in makes #include work for
|
||||
" headers in the same directory.
|
||||
return 'gcc -S -x c++ -fsyntax-only '
|
||||
\ . '-iquote ' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
\ . '-iquote ' . shellescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
\ . ' ' . ale#Var(a:buffer, 'cpp_gcc_options') . ' -'
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
function! ale_linters#css#csslint#GetCommand(buffer) abort
|
||||
let l:csslintrc = ale#path#FindNearestFile(a:buffer, '.csslintrc')
|
||||
let l:config_option = !empty(l:csslintrc)
|
||||
\ ? '--config=' . fnameescape(l:csslintrc)
|
||||
\ ? '--config=' . shellescape(l:csslintrc)
|
||||
\ : ''
|
||||
|
||||
return 'csslint --format=compact ' . l:config_option . ' %t'
|
||||
|
||||
@@ -31,7 +31,7 @@ function! ale_linters#d#dmd#DUBCommand(buffer) abort
|
||||
" To support older dub versions, we just change the directory to
|
||||
" the directory where we found the dub config, and then run `dub describe`
|
||||
" from that directory.
|
||||
return 'cd ' . fnameescape(fnamemodify(l:dub_file, ':h'))
|
||||
return 'cd ' . shellescape(fnamemodify(l:dub_file, ':h'))
|
||||
\ . ' && dub describe --import-paths'
|
||||
endfunction
|
||||
|
||||
@@ -42,7 +42,7 @@ function! ale_linters#d#dmd#DMDCommand(buffer, dub_output) abort
|
||||
for l:line in a:dub_output
|
||||
if !empty(l:line)
|
||||
" The arguments must be '-Ifilename', not '-I filename'
|
||||
call add(l:import_list, '-I' . fnameescape(l:line))
|
||||
call add(l:import_list, '-I' . shellescape(l:line))
|
||||
endif
|
||||
endfor
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ function! ale_linters#elm#make#GetCommand(buffer) abort
|
||||
let l:dir_set_cmd = ''
|
||||
else
|
||||
let l:root_dir = fnamemodify(l:elm_package, ':p:h')
|
||||
let l:dir_set_cmd = 'cd ' . fnameescape(l:root_dir) . ' && '
|
||||
let l:dir_set_cmd = 'cd ' . shellescape(l:root_dir) . ' && '
|
||||
endif
|
||||
|
||||
" The elm-make compiler, at the time of this writing, uses '/dev/null' as
|
||||
|
||||
@@ -6,7 +6,7 @@ function! ale_linters#erlang#erlc#GetCommand(buffer) abort
|
||||
let l:output_file = tempname()
|
||||
call ale#engine#ManageFile(a:buffer, l:output_file)
|
||||
|
||||
return 'erlc -o ' . fnameescape(l:output_file)
|
||||
return 'erlc -o ' . shellescape(l:output_file)
|
||||
\ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
@@ -8,7 +8,7 @@ endif
|
||||
function! ale_linters#go#gometalinter#GetCommand(buffer) abort
|
||||
return 'gometalinter '
|
||||
\ . ale#Var(a:buffer, 'go_gometalinter_options')
|
||||
\ . ' ' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
\ . ' ' . shellescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#go#gometalinter#GetMatches(lines) abort
|
||||
|
||||
@@ -41,14 +41,13 @@ endfunction
|
||||
function! s:BuildClassPathOption(buffer, import_paths) abort
|
||||
" Filter out lines like [INFO], etc.
|
||||
let l:class_paths = filter(a:import_paths[:], 'v:val !~# ''[''')
|
||||
call map(l:class_paths, 'fnameescape(v:val)')
|
||||
call extend(
|
||||
\ l:class_paths,
|
||||
\ split(ale#Var(a:buffer, 'java_javac_classpath'), s:classpath_sep),
|
||||
\)
|
||||
|
||||
return !empty(l:class_paths)
|
||||
\ ? '-cp ' . join(l:class_paths, s:classpath_sep)
|
||||
\ ? '-cp ' . shellescape(join(l:class_paths, s:classpath_sep))
|
||||
\ : ''
|
||||
endfunction
|
||||
|
||||
@@ -65,7 +64,7 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
|
||||
let l:src_dir = ale#path#FindNearestDirectory(a:buffer, 'src/main/java')
|
||||
|
||||
if !empty(l:src_dir)
|
||||
let l:sp_option = '-sourcepath ' . fnameescape(l:src_dir)
|
||||
let l:sp_option = '-sourcepath ' . shellescape(l:src_dir)
|
||||
endif
|
||||
|
||||
" Create .class files in a temporary directory, which we will delete later.
|
||||
@@ -74,7 +73,7 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
|
||||
return 'javac -Xlint'
|
||||
\ . ' ' . l:cp_option
|
||||
\ . ' ' . l:sp_option
|
||||
\ . ' -d ' . fnameescape(l:class_file_directory)
|
||||
\ . ' -d ' . shellescape(l:class_file_directory)
|
||||
\ . ' ' . ale#Var(a:buffer, 'java_javac_options')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
@@ -34,7 +34,7 @@ function! ale_linters#javascript#eslint#GetExecutable(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#javascript#eslint#GetCommand(buffer) abort
|
||||
return fnameescape(ale_linters#javascript#eslint#GetExecutable(a:buffer))
|
||||
return shellescape(ale_linters#javascript#eslint#GetExecutable(a:buffer))
|
||||
\ . ' ' . ale#Var(a:buffer, 'javascript_eslint_options')
|
||||
\ . ' -f unix --stdin --stdin-filename %s'
|
||||
endfunction
|
||||
|
||||
@@ -27,7 +27,7 @@ function! ale_linters#javascript#flow#GetCommand(buffer) abort
|
||||
return ''
|
||||
endif
|
||||
|
||||
return fnameescape(ale_linters#javascript#flow#GetExecutable(a:buffer))
|
||||
return shellescape(ale_linters#javascript#flow#GetExecutable(a:buffer))
|
||||
\ . ' check-contents --respect-pragma --json --from ale %s'
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ function! ale_linters#javascript#jshint#GetCommand(buffer) abort
|
||||
\ get(g:, 'ale_jshint_config_loc', '')
|
||||
\)
|
||||
|
||||
let l:command = fnameescape(ale_linters#javascript#jshint#GetExecutable(a:buffer))
|
||||
let l:command = shellescape(ale_linters#javascript#jshint#GetExecutable(a:buffer))
|
||||
let l:command .= ' --reporter unix --extract auto'
|
||||
|
||||
if !empty(l:jshint_config)
|
||||
let l:command .= ' --config ' . fnameescape(l:jshint_config)
|
||||
let l:command .= ' --config ' . shellescape(l:jshint_config)
|
||||
endif
|
||||
|
||||
let l:command .= ' -'
|
||||
|
||||
@@ -23,7 +23,7 @@ function! ale_linters#javascript#standard#GetExecutable(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#javascript#standard#GetCommand(buffer) abort
|
||||
return fnameescape(ale_linters#javascript#standard#GetExecutable(a:buffer))
|
||||
return shellescape(ale_linters#javascript#standard#GetExecutable(a:buffer))
|
||||
\ . ' ' . ale#Var(a:buffer, 'javascript_standard_options')
|
||||
\ . ' --stdin %s'
|
||||
endfunction
|
||||
|
||||
@@ -23,7 +23,7 @@ function! ale_linters#javascript#xo#GetExecutable(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#javascript#xo#GetCommand(buffer) abort
|
||||
return fnameescape(ale_linters#javascript#xo#GetExecutable(a:buffer))
|
||||
return shellescape(ale_linters#javascript#xo#GetExecutable(a:buffer))
|
||||
\ . ' ' . ale#Var(a:buffer, 'javascript_xo_options')
|
||||
\ . ' --reporter unix --stdin --stdin-filename %s'
|
||||
endfunction
|
||||
|
||||
@@ -16,13 +16,13 @@ function! ale_linters#kotlin#kotlinc#GetCommand(buffer) abort
|
||||
" If the config file is enabled and readable, source it
|
||||
if ale#Var(a:buffer, 'kotlin_kotlinc_enable_config')
|
||||
if filereadable(expand(ale#Var(a:buffer, 'kotlin_kotlinc_config_file'), 1))
|
||||
execute 'source ' . fnameescape(expand(ale#Var(a:buffer, 'kotlin_kotlinc_config_file'), 1))
|
||||
execute 'source ' . shellescape(expand(ale#Var(a:buffer, 'kotlin_kotlinc_config_file'), 1))
|
||||
endif
|
||||
endif
|
||||
|
||||
" If use module and module file is readable use that and return
|
||||
if ale#Var(a:buffer, 'kotlin_kotlinc_use_module_file')
|
||||
let l:module_filename = fnameescape(expand(ale#Var(a:buffer, 'kotlin_kotlinc_module_filename'), 1))
|
||||
let l:module_filename = shellescape(expand(ale#Var(a:buffer, 'kotlin_kotlinc_module_filename'), 1))
|
||||
|
||||
if filereadable(l:module_filename)
|
||||
let l:kotlinc_opts .= ' -module ' . l:module_filename
|
||||
|
||||
@@ -12,7 +12,7 @@ function! ale_linters#lua#luacheck#GetExecutable(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#lua#luacheck#GetCommand(buffer) abort
|
||||
return ale_linters#lua#luacheck#GetExecutable(a:buffer)
|
||||
return shellescape(ale_linters#lua#luacheck#GetExecutable(a:buffer))
|
||||
\ . ' ' . ale#Var(a:buffer, 'lua_luacheck_options')
|
||||
\ . ' --formatter plain --codes --filename %s -'
|
||||
endfunction
|
||||
|
||||
@@ -44,7 +44,7 @@ endfunction
|
||||
|
||||
|
||||
function! ale_linters#nim#nimcheck#GetCommand(buffer) abort
|
||||
let l:directory = fnameescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
let l:directory = shellescape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
|
||||
return 'nim check --path:' . l:directory
|
||||
\ . ' --threads:on --verbosity:0 --colors:off --listFullPaths %t'
|
||||
|
||||
@@ -48,7 +48,7 @@ function! ale_linters#python#flake8#VersionCheck(buffer) abort
|
||||
return ''
|
||||
endif
|
||||
|
||||
let l:executable = fnameescape(ale_linters#python#flake8#GetExecutable(a:buffer))
|
||||
let l:executable = shellescape(ale_linters#python#flake8#GetExecutable(a:buffer))
|
||||
let l:module_string = s:UsingModule(a:buffer) ? ' -m flake8' : ''
|
||||
|
||||
return l:executable . l:module_string . ' --version'
|
||||
@@ -89,7 +89,7 @@ function! ale_linters#python#flake8#GetCommand(buffer, version_output) abort
|
||||
|
||||
let l:options = ale#Var(a:buffer, 'python_flake8_options')
|
||||
|
||||
return fnameescape(ale_linters#python#flake8#GetExecutable(a:buffer))
|
||||
return shellescape(ale_linters#python#flake8#GetExecutable(a:buffer))
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . l:display_name_args . ' -'
|
||||
endfunction
|
||||
|
||||
@@ -30,7 +30,7 @@ function! ale_linters#python#mypy#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#python#mypy#GetExecutable(a:buffer)
|
||||
|
||||
return l:cd_command
|
||||
\ . fnameescape(l:executable)
|
||||
\ . shellescape(l:executable)
|
||||
\ . ' --show-column-numbers '
|
||||
\ . ale#Var(a:buffer, 'python_mypy_options')
|
||||
\ . ' %s'
|
||||
|
||||
@@ -26,7 +26,7 @@ function! ale_linters#python#pylint#GetExecutable(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#pylint#GetCommand(buffer) abort
|
||||
return fnameescape(ale_linters#python#pylint#GetExecutable(a:buffer))
|
||||
return shellescape(ale_linters#python#pylint#GetExecutable(a:buffer))
|
||||
\ . ' ' . ale#Var(a:buffer, 'python_pylint_options')
|
||||
\ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n'
|
||||
\ . ' %s'
|
||||
|
||||
@@ -18,7 +18,7 @@ function! ale_linters#tex#chktex#GetCommand(buffer) abort
|
||||
let l:command .= ' -v0 -p stdin -q'
|
||||
|
||||
if !empty(l:chktex_config)
|
||||
let l:command .= ' -l ' . fnameescape(l:chktex_config)
|
||||
let l:command .= ' -l ' . shellescape(l:chktex_config)
|
||||
endif
|
||||
|
||||
let l:command .= ' ' . ale#Var(a:buffer, 'tex_chktex_options')
|
||||
|
||||
@@ -55,7 +55,7 @@ function! ale_linters#typescript#tslint#BuildLintCommand(buffer) abort
|
||||
\)
|
||||
|
||||
let l:tslint_config_option = !empty(l:tslint_config_path)
|
||||
\ ? '-c ' . fnameescape(l:tslint_config_path)
|
||||
\ ? '-c ' . shellescape(l:tslint_config_path)
|
||||
\ : ''
|
||||
|
||||
return ale_linters#typescript#tslint#GetExecutable(a:buffer)
|
||||
|
||||
@@ -8,7 +8,7 @@ function! ale_linters#verilog#verilator#GetCommand(buffer) abort
|
||||
call ale#engine#ManageFile(a:buffer, l:filename)
|
||||
call writefile(getbufline(a:buffer, 1, '$'), l:filename)
|
||||
|
||||
return 'verilator --lint-only -Wall -Wno-DECLFILENAME ' . fnameescape(l:filename)
|
||||
return 'verilator --lint-only -Wall -Wno-DECLFILENAME ' . shellescape(l:filename)
|
||||
endfunction
|
||||
|
||||
function! ale_linters#verilog#verilator#Handle(buffer, lines) abort
|
||||
|
||||
Reference in New Issue
Block a user