Commit: patch 9.2.0986: long options are accepted with a trailing garbage
Christian Brabandt <[email protected]>
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <[email protected]> |
patch 9.2.0986: long options are accepted with a trailing garbage Commit: https://github.com/vim/vim/commit/5eaa0f4ddaeeb07868af5a30699f75d03f9f3d23 Author: Christoffer Aasted <[email protected]> Date: Thu Aug 20 19:56:26 2026 +0000 patch 9.2.0986: long options are accepted with a trailing garbage Problem: long options are accepted with a trailing garbage Solution: Compare the whole option name instead of a prefix (Christoffer Aasted) closes: #21088 Signed-off-by: Christoffer Aasted <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> diff --git a/src/main.c b/src/main.c index 95d0494a1..7b5f6aa4c 100644 --- a/src/main.c +++ b/src/main.c @@ -1921,7 +1921,7 @@ early_arg_scan(mparm_T *parmp UNUSED) # endif } # ifdef FEAT_CLIENTSERVER_BACKENDS - else if (STRNICMP(argv[i], "--clientserver", 14) == 0) + else if (STRICMP(argv[i], "--clientserver") == 0) { char_u *arg; if (i == argc - 1) @@ -2263,13 +2263,13 @@ command_line_scan(mparm_T *parmp) argv_idx += 3; } # ifdef FEAT_CLIENTSERVER - else if (STRNICMP(argv[0] + argv_idx, "serverlist", 10) == 0) + else if (STRICMP(argv[0] + argv_idx, "serverlist") == 0) ; // already processed -- no arg - else if (STRNICMP(argv[0] + argv_idx, "servername", 10) == 0 - || STRNICMP(argv[0] + argv_idx, "serversend", 10) == 0 + else if (STRICMP(argv[0] + argv_idx, "servername") == 0 + || STRICMP(argv[0] + argv_idx, "serversend") == 0 // Don't put this under FEAT_CLIENTSERVER_BACKENDS, just // let it be ignored. Makes tests less complicated - || STRNICMP(argv[0] + argv_idx, "clientserver", 12) == 0 + || STRICMP(argv[0] + argv_idx, "clientserver") == 0 ) { // already processed -- snatch the following arg diff --git a/src/testdir/test_startup.vim b/src/testdir/test_startup.vim index 04e4447b0..aaaf0bb41 100644 --- a/src/testdir/test_startup.vim +++ b/src/testdir/test_startup.vim @@ -985,6 +985,28 @@ func Test_v_argv() call assert_equal(['arg1', '--cmd', 'echo v:argv', '--cmd', 'q'']'], list[idx:]) endfunc +func Test_longopt_prefix_not_accepted() + CheckNotGui + CheckFeature clientserver + + let command = printf('%s -es -X -i NONE -n', GetVimCommand()) + for args in ['--serverlistx', + \ '--servername=XtestName', + \ '--serversend=foo', + \ '--clientserver=socket'] + let out = system($'{command} {args}') + call assert_notequal(0, v:shell_error, args) + call assert_match('Unknown option', out, args) + endfor + + " The documented forms still work. + for args in ['--servername XtestName --serverlist', + \ '--servername XtestName -c quit'] + call system($'{command} {args}') + call assert_equal(0, v:shell_error, args) + endfor +endfunc + " Test for the "-r" recovery mode option func Test_r_arg() " Can't catch the output of gvim. diff --git a/src/version.c b/src/version.c index 535e5df2b..dab9b2df2 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 986, /**/ 985, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wx9AG-00E1re-PZ%40256bit.org.