Mercurial > vim
annotate runtime/ftplugin/awk.vim @ 33716:bd3ee5abdd7a
runtime(dist): centralize safe executable check and add vim library (#13413)
Commit: https://github.com/vim/vim/commit/cd8a3eaf5348feacfecab4b374b7ea4ce6a97422
Author: D. Ben Knoble <ben.knoble+github@gmail.com>
Date: Sat Nov 4 05:11:17 2023 -0400
runtime(dist): centralize safe executable check and add vim library (https://github.com/vim/vim/issues/13413)
Follow up to 816fbcc26 (patch 9.0.1833: [security] runtime file fixes,
2023-08-31) and f7ac0ef50 (runtime: don't execute external commands when
loading ftplugins, 2023-09-06).
This puts the logic for safe executable checks in a single place, by introducing
a central vim library, so all filetypes benefit from consistency.
Notable changes:
- dist#vim because the (autoload) namespace for a new runtime support
library. Supporting functions should get documentation. It might make
life easier for NeoVim devs to make the documentation a new file
rather than cram it into existing files, though we may want
cross-references to it somewhere?
- The gzip and zip plugins need to be opted into by enabling execution
of those programs (or the global plugin_exec). This needs
documentation or discussion.
- This fixes a bug in the zig plugin: code setting s:tmp_cwd was removed
in f7ac0ef50 (runtime: don't execute external commands when loading
ftplugins, 2023-09-06), but the variable was still referenced. Since
the new function takes care of that automatically, the variable is no
longer needed.
Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 04 Nov 2023 10:15:06 +0100 |
parents | c3c347a71e05 |
children | 8ae680be2a51 |
rev | line source |
---|---|
10895 | 1 " Vim filetype plugin |
22824 | 2 " Language: awk, nawk, gawk, mawk |
3 " Maintainer: Doug Kearns <dougkearns@gmail.com> | |
4 " Previous Maintainer: Antonio Colombo <azc100@gmail.com> | |
5 " Last Change: 2020 Sep 28 | |
10895 | 6 |
7 " This plugin was prepared by Mark Sikora | |
22441 | 8 " This plugin was updated as proposed by Doug Kearns |
10895 | 9 |
10 " Only do this when not done yet for this buffer | |
11 if exists("b:did_ftplugin") | |
12 finish | |
13 endif | |
14 | |
15 " Don't load another plugin for this buffer | |
16 let b:did_ftplugin = 1 | |
17 | |
22441 | 18 let s:cpo_save = &cpo |
19 set cpo&vim | |
20 | |
21 setlocal comments=:# | |
22 setlocal commentstring=#\ %s | |
23 setlocal formatoptions-=t formatoptions+=croql | |
24 | |
25 setlocal define=function | |
26 setlocal suffixesadd+=.awk | |
27 | |
28 let b:undo_ftplugin = "setl fo< com< cms< def< sua<" . | |
29 \ " | unlet! b:browsefilter" | |
10895 | 30 |
22441 | 31 " TODO: set this in scripts.vim? |
32 if exists("g:awk_is_gawk") | |
33 setlocal include=@include | |
34 setlocal suffixesadd+=.gawk | |
35 if has("unix") || has("win32unix") | |
36 setlocal formatprg=gawk\ -f-\ -o/dev/stdout | |
37 let b:undo_ftplugin .= " | setl fp<" | |
38 endif | |
39 | |
33716
bd3ee5abdd7a
runtime(dist): centralize safe executable check and add vim library (#13413)
Christian Brabandt <cb@256bit.org>
parents:
33203
diff
changeset
|
40 " Disabled by default for security reasons. |
bd3ee5abdd7a
runtime(dist): centralize safe executable check and add vim library (#13413)
Christian Brabandt <cb@256bit.org>
parents:
33203
diff
changeset
|
41 if dist#vim#IsSafeExecutable('awk', 'gawk') |
33203
c3c347a71e05
runtime: don't execute external commands when loading ftplugins
Christian Brabandt <cb@256bit.org>
parents:
22824
diff
changeset
|
42 let path = system("gawk 'BEGIN { printf ENVIRON[\"AWKPATH\"] }'") |
c3c347a71e05
runtime: don't execute external commands when loading ftplugins
Christian Brabandt <cb@256bit.org>
parents:
22824
diff
changeset
|
43 let path = substitute(path, '^\.\=:\|:\.\=$\|:\.\=:', ',,', 'g') " POSIX cwd |
c3c347a71e05
runtime: don't execute external commands when loading ftplugins
Christian Brabandt <cb@256bit.org>
parents:
22824
diff
changeset
|
44 let path = substitute(path, ':', ',', 'g') |
22441 | 45 |
33203
c3c347a71e05
runtime: don't execute external commands when loading ftplugins
Christian Brabandt <cb@256bit.org>
parents:
22824
diff
changeset
|
46 let &l:path = path |
c3c347a71e05
runtime: don't execute external commands when loading ftplugins
Christian Brabandt <cb@256bit.org>
parents:
22824
diff
changeset
|
47 endif |
22441 | 48 let b:undo_ftplugin .= " | setl inc< path<" |
49 endif | |
50 | |
51 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") | |
52 let b:browsefilter = "Awk Source Files (*.awk,*.gawk)\t*.awk;*.gawk\n" . | |
53 \ "All Files (*.*)\t*.*\n" | |
54 endif | |
55 | |
56 let &cpo = s:cpo_save | |
57 unlet s:cpo_save | |
58 | |
59 " vim: nowrap sw=2 sts=2 ts=8 |