To: vim_dev@googlegroups.com Subject: Patch 8.1.0613 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0613 Problem: When executing an insecure function the secure flag is stuck. (Gabriel Barta) Solution: Restore "secure" instead of decrementing it. (closes #3705) Files: src/testdir/test_autocmd.vim, src/option.c, src/buffer.c *** ../vim-8.1.0612/src/testdir/test_autocmd.vim 2018-12-16 15:37:58.866807609 +0100 --- src/testdir/test_autocmd.vim 2018-12-21 12:56:42.539308810 +0100 *************** *** 650,655 **** --- 650,677 ---- "delfunc! AutoCommandOptionSet endfunc + func Test_OptionSet_modeline() + call test_override('starting', 1) + au! OptionSet + augroup set_tabstop + au OptionSet tabstop call timer_start(1, {-> execute("echo 'Handler called'", "")}) + augroup END + call writefile(['vim: set ts=7 sw=5 :', 'something'], 'XoptionsetModeline') + set modeline + let v:errmsg = '' + call assert_fails('split XoptionsetModeline', 'E12:') + call assert_equal(7, &ts) + call assert_equal('', v:errmsg) + + augroup set_tabstop + au! + augroup END + bwipe! + set ts& + call delete('XoptionsetModeline') + call test_override('starting', 0) + endfunc + " Test for Bufleave autocommand that deletes the buffer we are about to edit. func Test_BufleaveWithDelete() new | edit Xfile1 *** ../vim-8.1.0612/src/option.c 2018-12-16 18:19:56.138140742 +0100 --- src/option.c 2018-12-21 12:54:17.032357226 +0100 *************** *** 5214,5220 **** { long_u *p = insecure_flag(opt_idx, opt_flags); ! int did_inc_secure = FALSE; // When an option is set in the sandbox, from a // modeline or in secure mode, then deal with side --- 5214,5220 ---- { long_u *p = insecure_flag(opt_idx, opt_flags); ! int secure_saved = secure; // When an option is set in the sandbox, from a // modeline or in secure mode, then deal with side *************** *** 5227,5247 **** #endif || (opt_flags & OPT_MODELINE) || (!value_is_replaced && (*p & P_INSECURE))) - { - did_inc_secure = TRUE; ++secure; - } ! // Handle side effects, and set the global value for ! // ":set" on local options. Note: when setting 'syntax' ! // or 'filetype' autocommands may be triggered that can ! // cause havoc. ! errmsg = did_set_string_option(opt_idx, (char_u **)varp, new_value_alloced, oldval, errbuf, opt_flags, &value_checked); ! if (did_inc_secure) ! --secure; } #if defined(FEAT_EVAL) --- 5227,5244 ---- #endif || (opt_flags & OPT_MODELINE) || (!value_is_replaced && (*p & P_INSECURE))) ++secure; ! // Handle side effects, and set the global value ! // for ":set" on local options. Note: when setting ! // 'syntax' or 'filetype' autocommands may be ! // triggered that can cause havoc. ! errmsg = did_set_string_option( ! opt_idx, (char_u **)varp, new_value_alloced, oldval, errbuf, opt_flags, &value_checked); ! secure = secure_saved; } #if defined(FEAT_EVAL) *** ../vim-8.1.0612/src/buffer.c 2018-12-13 22:17:52.873941502 +0100 --- src/buffer.c 2018-12-21 12:55:36.679783373 +0100 *************** *** 5519,5524 **** --- 5519,5525 ---- if (*s != NUL) /* skip over an empty "::" */ { + int secure_save = secure; #ifdef FEAT_EVAL save_current_sctx = current_sctx; current_sctx.sc_sid = SID_MODELINE; *************** *** 5530,5536 **** retval = do_set(s, OPT_MODELINE | OPT_LOCAL | flags); ! --secure; #ifdef FEAT_EVAL current_sctx = save_current_sctx; #endif --- 5531,5537 ---- retval = do_set(s, OPT_MODELINE | OPT_LOCAL | flags); ! secure = secure_save; #ifdef FEAT_EVAL current_sctx = save_current_sctx; #endif *** ../vim-8.1.0612/src/version.c 2018-12-21 11:48:48.324680461 +0100 --- src/version.c 2018-12-21 12:52:28.649137990 +0100 *************** *** 801,802 **** --- 801,804 ---- { /* Add new patch number below this line */ + /**/ + 613, /**/ -- Give a man a computer program and you give him a headache, but teach him to program computers and you give him the power to create headaches for others for the rest of his life... R. B. Forest /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///