diff --git a/doc/starting.jax b/doc/starting.jax index 0e13fc134..2b08acec2 100644 --- a/doc/starting.jax +++ b/doc/starting.jax @@ -1,4 +1,4 @@ -*starting.txt* For Vim バージョン 9.2. Last change: 2026 Mar 17 +*starting.txt* For Vim バージョン 9.2. Last change: 2026 Apr 29 VIM リファレンスマニュアル by Bram Moolenaar @@ -1546,6 +1546,26 @@ viminfoファイルにはこんなものを記憶できる: ションファイルどちらも、Vimをスタートしてすぐに好みの設定を行うという目的のた めに、効果的に使用できる。 |session-file| + *viminfo-security* +Vim によって書き込まれる viminfo ファイルはプレーンテキストであり、 +|List|、|Dictionary|、|Tuple| の値に対応する Vim 式が含まれている。Vim が +viminfo ファイルとして処理する際に、'viminfo' に "!" が含まれている場合、それ +らの式が評価される。 + +'viminfo' のデフォルト値には "!" が含まれていないため、デフォルトでは式の評価 +は行われない。 + +バッファで viminfo ファイルを開くこと (例えば |:edit| を使う) は無害である。 +Vim はファイルの内容を表示するだけである。リスクとなるのは、信頼できないファイ +ルを viminfo の仕組みを通して Vim に処理させてしまう場合である。これは以下のよ +うな場合に発生する: +- |:rviminfo| がファイルで使用されている、または、 +- 'viminfofile' がそれを指すように設定されている、または、 +- ファイルは、Vim が既に viminfo |viminfo-file-name| として読み込んでいるパス + に配置される + +いずれの場合も、信頼できない場合は 'viminfo' に "!" を含めないこと。 + *viminfo-read* Vimが起動した時に 'viminfo' オプションが空でなかったら、viminfoファイルが読み 込まれ、その情報は適切に使用される。変数 |v:oldfiles| がセットされる。起動時に diff --git a/en/starting.txt b/en/starting.txt index 46a47b7e2..816849fb9 100644 --- a/en/starting.txt +++ b/en/starting.txt @@ -1,4 +1,4 @@ -*starting.txt* For Vim version 9.2. Last change: 2026 Mar 17 +*starting.txt* For Vim version 9.2. Last change: 2026 Apr 29 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1573,6 +1573,24 @@ Session. You could have several Session files, one for each project you are working on. Viminfo and Session files together can be used to effectively enter Vim and directly start working in your desired setup. |session-file| + *viminfo-security* +A viminfo file written by Vim is plain text and contains Vim expressions for +|List|, |Dictionary| and |Tuple| values. When "!" is in 'viminfo' at the time +Vim processes the file as a viminfo file, those expressions are evaluated. + +The default value of 'viminfo' does not include "!", so by default no +expression evaluation happens. + +Opening a viminfo file in a buffer (e.g. with |:edit|) is harmless; Vim only +displays the file contents. The risk is letting Vim process an untrusted file +through the viminfo machinery, which happens when: +- |:rviminfo| is used on the file, or +- 'viminfofile' is set to point at it, or +- the file is placed at the path Vim already reads as viminfo + |viminfo-file-name| + +In any of those cases, do not have "!" in 'viminfo' if you do not trust it. + *viminfo-read* When Vim is started and the 'viminfo' option is non-empty, the contents of the viminfo file are read and the info can be used in the appropriate places.