" vim: set sw=4 sts=4 et ft=vim :
" Script: securemodelines.vim
-" Version: 20070518
-" Author: Ciaran McCreesh <ciaranm@ciaranm.org>
-" Homepage: http://ciaranm.org/tag/securemodelines
+" Version: ca214e9f709242313e94f0f7ab3a4058058b2ba2
+" Author: Ciaran McCreesh <ciaran.mccreesh at googlemail.com>
+" Homepage: http://github.com/ciaranm/securemodelines
" Requires: Vim 7
" License: Redistribute under the same terms as Vim itself
" Purpose: A secure alternative to modelines
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
endfun
fun! <SID>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 <SID>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
endfun
fun! <SID>DoModeline(line) abort
- let l:matches = matchlist(a:line, '\%(\S\@<!\%(vi\|vim\([<>=]\?\)\([0-9]\+\)\?\)\|\sex\):\s*set\?\s\+\([^:]\+\):\S\@!')
+ let l:matches = matchlist(a:line, '\%(\S\@<!\%(vi\|vim\([<>=]\?\)\([0-9]\+\)\?\)\|\sex\):\s*\%(set\s\+\)\?\([^:]\+\):\S\@!')
if len(l:matches) > 0
let l:operator = ">"
if len(l:matches[1]) > 0
aug SecureModeLines
au!
- au BufRead * :call <SID>DoModelines()
+ au BufRead,StdinReadPost * :call <SID>DoModelines()
aug END