diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-08-21 07:35:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-20 23:35:27 +0000 |
commit | 6f7bb02e7f7b8ff8fe4d67a433cd3a2250df7a11 (patch) | |
tree | a88221e61374e5bbd11cb5b7707807a7518c1b03 /test | |
parent | a9e11168f5b402940d494e0cdc36b9952e4f8fab (diff) | |
download | rneovim-6f7bb02e7f7b8ff8fe4d67a433cd3a2250df7a11.tar.gz rneovim-6f7bb02e7f7b8ff8fe4d67a433cd3a2250df7a11.tar.bz2 rneovim-6f7bb02e7f7b8ff8fe4d67a433cd3a2250df7a11.zip |
vim-patch:9.1.0686: zip-plugin has problems with special characters (#30108)
Problem: zip-plugin has problems with special characters
(user202729)
Solution: escape '*?[\' on Unix and handle those chars
a bit differently on MS-Windows, add a test, check
before overwriting files
runtime(zip): small fixes for zip plugin
This does the following:
- verify the unzip plugin is executable when loading the autoload plugin
- handle extracting file names with '[*?\' in its name correctly by
escaping those characters for the unzip command (and handle those
characters a bit differently on MS-Windows, since the quoting is different)
- verify, that the extract plugin is not overwriting a file (could cause
a hang, because unzip asking for confirmation)
- add a test zip file which contains those special file names
fixes: vim/vim#15505
closes: vim/vim#15519
https://github.com/vim/vim/commit/7790ea0c680a9f951a86066e5940ec16b2333c9a
Co-authored-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/old/testdir/samples/testa.zip | bin | 0 -> 1236 bytes | |||
-rw-r--r-- | test/old/testdir/test_zip_plugin.vim | 104 |
2 files changed, 103 insertions, 1 deletions
diff --git a/test/old/testdir/samples/testa.zip b/test/old/testdir/samples/testa.zip Binary files differnew file mode 100644 index 0000000000..10b0346e76 --- /dev/null +++ b/test/old/testdir/samples/testa.zip diff --git a/test/old/testdir/test_zip_plugin.vim b/test/old/testdir/test_zip_plugin.vim index b214516e05..a817d8371e 100644 --- a/test/old/testdir/test_zip_plugin.vim +++ b/test/old/testdir/test_zip_plugin.vim @@ -40,7 +40,8 @@ func Test_zip_basic() \ execute("normal \<CR>")) "## Check ENTER on file - :1|:/^$//file/ + :1 + call search('file.txt') exe ":normal \<cr>" call assert_match('zipfile://.*/X.zip::Xzip/file.txt', @%) call assert_equal('one', getline(1)) @@ -65,6 +66,10 @@ func Test_zip_basic() :1|:/^$//file/ normal x call assert_true(filereadable("Xzip/file.txt")) + + "## Check not overwriting existing file + call assert_match('<Xzip/file.txt> .* not overwriting!', execute("normal x")) + call delete("Xzip", "rf") "## Check extracting directory @@ -131,5 +136,102 @@ func Test_zip_basic() call assert_match('File not readable', execute("e Xnot_exists.zip")) bw +endfunc + +func Test_zip_glob_fname() + CheckNotMSWindows + " does not work on Windows, why? + + "## copy sample zip file + if !filecopy("samples/testa.zip", "X.zip") + call assert_report("Can't copy samples/testa.zip") + return + endif + defer delete("X.zip") + defer delete('zipglob', 'rf') + + e X.zip + + "## 1) Check extracting strange files + :1 + let fname = 'a[a].txt' + call search('\V' .. fname) + normal x + call assert_true(filereadable('zipglob/' .. fname)) + call delete('zipglob', 'rf') + + :1 + let fname = 'a*.txt' + call search('\V' .. fname) + normal x + call assert_true(filereadable('zipglob/' .. fname)) + call delete('zipglob', 'rf') + + :1 + let fname = 'a?.txt' + call search('\V' .. fname) + normal x + call assert_true(filereadable('zipglob/' .. fname)) + call delete('zipglob', 'rf') + + :1 + let fname = 'a\.txt' + call search('\V' .. escape(fname, '\\')) + normal x + call assert_true(filereadable('zipglob/' .. fname)) + call delete('zipglob', 'rf') + + :1 + let fname = 'a\\.txt' + call search('\V' .. escape(fname, '\\')) + normal x + call assert_true(filereadable('zipglob/' .. fname)) + call delete('zipglob', 'rf') + + "## 2) Check entering strange file names + :1 + let fname = 'a[a].txt' + call search('\V' .. fname) + exe ":normal \<cr>" + call assert_match('zipfile://.*/X.zip::zipglob/a\[a\].txt', @%) + call assert_equal('a test file with []', getline(1)) + bw + + e X.zip + :1 + let fname = 'a*.txt' + call search('\V' .. fname) + exe ":normal \<cr>" + call assert_match('zipfile://.*/X.zip::zipglob/a\*.txt', @%) + call assert_equal('a test file with a*', getline(1)) + bw + + e X.zip + :1 + let fname = 'a?.txt' + call search('\V' .. fname) + exe ":normal \<cr>" + call assert_match('zipfile://.*/X.zip::zipglob/a?.txt', @%) + call assert_equal('a test file with a?', getline(1)) + bw + + e X.zip + :1 + let fname = 'a\.txt' + call search('\V' .. escape(fname, '\\')) + exe ":normal \<cr>" + call assert_match('zipfile://.*/X.zip::zipglob/a\\.txt', @%) + call assert_equal('a test file with a\', getline(1)) + bw + e X.zip + :1 + let fname = 'a\\.txt' + call search('\V' .. escape(fname, '\\')) + exe ":normal \<cr>" + call assert_match('zipfile://.*/X.zip::zipglob/a\\\\.txt', @%) + call assert_equal('a test file with a double \', getline(1)) + bw + + bw endfunc |