X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=vim%2Fplugin%2Fsecuremodelines.vim;h=2893b4892b97a23b89cb43dd4cc71f35f4a962e6;hb=9a0f2622b2127e1775945e1781f80598c7191151;hp=bb4b60f714c0ee54f8fa16060ca4d943e684bff5;hpb=9f610fb453be88ea9c03a451054eb3c6d0e62efa;p=config%2Fdotfiles.git diff --git a/vim/plugin/securemodelines.vim b/vim/plugin/securemodelines.vim index bb4b60f..2893b48 100644 --- a/vim/plugin/securemodelines.vim +++ b/vim/plugin/securemodelines.vim @@ -1,17 +1,13 @@ " vim: set sw=4 sts=4 et ft=vim : " Script: securemodelines.vim -" Version: 20070518 -" Author: Ciaran McCreesh -" Homepage: http://ciaranm.org/tag/securemodelines +" Version: 10d6c6b52fcdd12f3ba457126f66fee4ccceec04 +" Author: Ciaran McCreesh +" Homepage: http://github.com/ciaranm/securemodelines " Requires: Vim 7 " License: Redistribute under the same terms as Vim itself " Purpose: A secure alternative to modelines -if &compatible || v:version < 700 - finish -endif - -if exists("g:loaded_securemodelines") +if &compatible || v:version < 700 || exists('g:loaded_securemodelines') finish endif let g:loaded_securemodelines = 1 @@ -27,6 +23,9 @@ if (! exists("g:secure_modelines_allowed_items")) \ "foldmethod", "fdm", \ "readonly", "ro", "noreadonly", "noro", \ "rightleft", "rl", "norightleft", "norl", + \ "cindent", "cin", "nocindent", "nocin", + \ "smartindent", "si", "nosmartindent", "nosi", + \ "autoindent", "ai", "noautoindent", "noai", \ "spell", \ "spelllang" \ ] @@ -45,7 +44,7 @@ if (! exists("g:secure_modelines_leave_modeline")) set nomodeline if g:secure_modelines_verbose echohl WarningMsg - echomsg "Forcibly disabling internal modelines for securemodelines.vim" + echo "Forcibly disabling internal modelines for securemodelines.vim" echohl None endif endif @@ -61,13 +60,13 @@ fun! IsInList(list, i) abort endfun fun! DoOne(item) abort - let l:matches = matchlist(a:item, '^\([a-z]\+\)\%(=[a-zA-Z0-9_\-.]\+\)\?$') + let l:matches = matchlist(a:item, '^\([a-z]\+\)\%([-+^]\?=[a-zA-Z0-9_\-.]\+\)\?$') if len(l:matches) > 0 if IsInList(g:secure_modelines_allowed_items, l:matches[1]) exec "setlocal " . a:item elseif g:secure_modelines_verbose echohl WarningMsg - echomsg "Ignoring '" . a:item . "' in modeline" + echo "Ignoring '" . a:item . "' in modeline" echohl None endif endif @@ -98,7 +97,7 @@ fun! CheckVersion(op, ver) abort endfun fun! DoModeline(line) abort - let l:matches = matchlist(a:line, '\%(\S\@=]\?\)\([0-9]\+\)\?\)\|\sex\):\s*set\?\s\+\([^:]\+\):\S\@!') + let l:matches = matchlist(a:line, '\%(\S\@=]\?\)\([0-9]\+\)\?\)\|\sex\):\s*\%(set\s\+\)\?\([^:]\+\):\S\@!') if len(l:matches) > 0 let l:operator = ">" if len(l:matches[1]) > 0 @@ -149,6 +148,6 @@ endfun aug SecureModeLines au! - au BufRead * :call DoModelines() + au BufRead,StdinReadPost * :call DoModelines() aug END