annotate runtime/ftplugin/perl.vim @ 29357:f4ff490d51a7 v9.0.0021

patch 9.0.0021: invalid memory access when adding word to spell word list Commit: https://github.com/vim/vim/commit/5e59ea54c0c37c2f84770f068d95280069828774 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jul 1 22:26:20 2022 +0100 patch 9.0.0021: invalid memory access when adding word to spell word list Problem: Invalid memory access when adding word with a control character to the internal spell word list. Solution: Disallow adding a word with control characters or a trailing slash.
author Bram Moolenaar <Bram@vim.org>
date Fri, 01 Jul 2022 23:30:02 +0200
parents d1fe80fb35e6
children 828bcb1a37e7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim filetype plugin file
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
2 " Language: Perl
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
3 " Maintainer: vim-perl <vim-perl@googlegroups.com>
20115
bd021eb62e73 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 12499
diff changeset
4 " Homepage: https://github.com/vim-perl/vim-perl
bd021eb62e73 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 12499
diff changeset
5 " Bugs/requests: https://github.com/vim-perl/vim-perl/issues
29150
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
6 " License: Vim License (see :help license)
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
7 " Last Change: 2021 Nov 10
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 if exists("b:did_ftplugin") | finish | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 let b:did_ftplugin = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 " Make sure the continuation lines below do not cause problems in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " compatibility mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 let s:save_cpo = &cpo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 set cpo-=C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
17 setlocal formatoptions-=t
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
18 setlocal formatoptions+=crqol
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1621
diff changeset
19 setlocal keywordprg=perldoc\ -f
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 setlocal comments=:#
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 setlocal commentstring=#%s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 " Provided by Ned Konz <ned at bike-nomad dot com>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 "---------------------------------------------
603
e4c00ec07598 updated for version 7.0171
vimboss
parents: 36
diff changeset
26 setlocal include=\\<\\(use\\\|require\\)\\>
29150
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
27 " '+' is removed to support plugins in Catalyst or DBIx::Class
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
28 " where the leading plus indicates a fully-qualified module name.
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
29 setlocal includeexpr=substitute(substitute(substitute(substitute(v:fname,'+','',''),'::','/','g'),'->\*','',''),'$','.pm','')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 setlocal define=[^A-Za-z_]
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5277
diff changeset
31 setlocal iskeyword+=:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 " The following line changes a global variable but is necessary to make
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5277
diff changeset
34 " gf and similar commands work. Thanks to Andrew Pimlott for pointing
29150
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
35 " out the problem.
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
36 let s:old_isfname = &isfname
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 set isfname+=:
29150
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
38 let s:new_isfname = &isfname
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
39
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
40 augroup perl_global_options
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
41 au!
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
42 exe "au BufEnter * if &filetype == 'perl' | let &isfname = '" . s:new_isfname . "' | endif"
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
43 exe "au BufLeave * if &filetype == 'perl' | let &isfname = '" . s:old_isfname . "' | endif"
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
44 augroup END
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
45
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
46 " Undo the stuff we changed.
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
47 let b:undo_ftplugin = "setlocal fo< kp< com< cms< inc< inex< def< isk<" .
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
48 \ " | let &isfname = '" . s:old_isfname . "'"
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
49
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
50 if get(g:, 'perl_fold', 0)
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
51 setlocal foldmethod=syntax
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
52 let b:undo_ftplugin .= " | setlocal fdm<"
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
53 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 " Set this once, globally.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 if !exists("perlpath")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 if executable("perl")
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 603
diff changeset
58 try
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 if &shellxquote != '"'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 let perlpath = system('perl -e "print join(q/,/,@INC)"')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 let perlpath = system("perl -e 'print join(q/,/,@INC)'")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 let perlpath = substitute(perlpath,',.$',',,','')
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 603
diff changeset
65 catch /E145:/
82b5078be2dd updated for version 7.2a
vimboss
parents: 603
diff changeset
66 let perlpath = ".,,"
82b5078be2dd updated for version 7.2a
vimboss
parents: 603
diff changeset
67 endtry
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 " If we can't call perl to get its path, just default to using the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 " current directory and the directory of the current file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 let perlpath = ".,,"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
75 " Append perlpath to the existing path value, if it is set. Since we don't
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
76 " use += to do it because of the commas in perlpath, we have to handle the
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
77 " global / local settings, too.
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
78 if &l:path == ""
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
79 if &g:path == ""
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
80 let &l:path=perlpath
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
81 else
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
82 let &l:path=&g:path.",".perlpath
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
83 endif
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
84 else
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
85 let &l:path=&l:path.",".perlpath
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
86 endif
29150
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
87
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
88 let b:undo_ftplugin .= " | setlocal pa<"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 "---------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
29150
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
91 " Change the browse dialog to show mainly Perl-related files
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
92 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
93 let b:browsefilter = "Perl Source Files (*.pl)\t*.pl\n" .
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
94 \ "Perl Modules (*.pm)\t*.pm\n" .
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
95 \ "Perl Documentation Files (*.pod)\t*.pod\n" .
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
96 \ "All Files (*.*)\t*.*\n"
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
97 let b:undo_ftplugin .= " | unlet! b:browsefilter"
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
98 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
29150
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
100 " Proper matching for matchit plugin
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
101 if exists("loaded_matchit") && !exists("b:match_words")
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
102 let b:match_skip = 's:comment\|string\|perlQQ\|perlShellCommand\|perlHereDoc\|perlSubstitution\|perlTranslation\|perlMatch\|perlFormatField'
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
103 let b:match_words = '\<if\>:\<elsif\>:\<else\>'
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
104 let b:undo_ftplugin .= " | unlet! b:match_words b:match_skip"
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
105 endif
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3410
diff changeset
106
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 " Restore the saved compatibility options.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 let &cpo = s:save_cpo
29150
d1fe80fb35e6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20115
diff changeset
109 unlet s:save_cpo s:old_isfname s:new_isfname