summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.1345
blob: 23746d0f17b19f8b7eee8b05c58e41d3ca7314c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
To: vim_dev@googlegroups.com
Subject: Patch 8.1.1345
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.1345
Problem:    Stuck in sandbox with ":s/../\=Function/gn".
Solution:   Don't skip over code to restore sandbox. (Christian Brabandt)
Files:	    src/ex_cmds.c, src/testdir/test_substitute.vim


*** ../vim-8.1.1344/src/ex_cmds.c	2019-05-15 22:45:33.956067651 +0200
--- src/ex_cmds.c	2019-05-18 13:39:18.862210027 +0200
***************
*** 5555,5582 ****
  #ifdef FEAT_EVAL
  		if (subflags.do_count)
  		{
! 		    /* prevent accidentally changing the buffer by a function */
! 		    save_ma = curbuf->b_p_ma;
  		    curbuf->b_p_ma = FALSE;
  		    sandbox++;
  		}
! 		/* Save flags for recursion.  They can change for e.g.
! 		 * :s/^/\=execute("s#^##gn") */
  		subflags_save = subflags;
  #endif
! 		/* get length of substitution part */
  		sublen = vim_regsub_multi(&regmatch,
  				    sub_firstlnum - regmatch.startpos[0].lnum,
  				    sub, sub_firstline, FALSE, p_magic, TRUE);
  #ifdef FEAT_EVAL
  		// If getting the substitute string caused an error, don't do
  		// the replacement.
- 		if (aborting())
- 		    goto skip;
- 
  		// Don't keep flags set by a recursive call.
  		subflags = subflags_save;
! 		if (subflags.do_count)
  		{
  		    curbuf->b_p_ma = save_ma;
  		    if (sandbox > 0)
--- 5555,5579 ----
  #ifdef FEAT_EVAL
  		if (subflags.do_count)
  		{
! 		    // prevent accidentally changing the buffer by a function
  		    curbuf->b_p_ma = FALSE;
  		    sandbox++;
  		}
! 		// Save flags for recursion.  They can change for e.g.
! 		// :s/^/\=execute("s#^##gn")
  		subflags_save = subflags;
+ 		save_ma = curbuf->b_p_ma;
  #endif
! 		// get length of substitution part
  		sublen = vim_regsub_multi(&regmatch,
  				    sub_firstlnum - regmatch.startpos[0].lnum,
  				    sub, sub_firstline, FALSE, p_magic, TRUE);
  #ifdef FEAT_EVAL
  		// If getting the substitute string caused an error, don't do
  		// the replacement.
  		// Don't keep flags set by a recursive call.
  		subflags = subflags_save;
! 		if (aborting() || subflags.do_count)
  		{
  		    curbuf->b_p_ma = save_ma;
  		    if (sandbox > 0)
*** ../vim-8.1.1344/src/testdir/test_substitute.vim	2019-04-27 18:00:29.851064563 +0200
--- src/testdir/test_substitute.vim	2019-05-18 13:35:12.383650094 +0200
***************
*** 638,643 ****
--- 638,654 ----
    call assert_equal(1, error_caught)
    call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3))
  
+   " Same, but using "n" flag so that "sandbox" gets set
+   call setline(1, ['1 aaa', '2 aaa', '3 aaa'])
+   let error_caught = 0
+   try
+     %s/aaa/\=Foo()/gn
+   catch
+     let error_caught = 1
+   endtry
+   call assert_equal(1, error_caught)
+   call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3))
+ 
    bwipe!
  endfunc
  
*** ../vim-8.1.1344/src/version.c	2019-05-18 13:05:12.470334000 +0200
--- src/version.c	2019-05-18 13:40:32.629781025 +0200
***************
*** 769,770 ****
--- 769,772 ----
  {   /* Add new patch number below this line */
+ /**/
+     1345,
  /**/

-- 
For large projects, Team Leaders use sophisticated project management software
to keep track of who's doing what.  The software collects the lies and guesses
of the project team and organizes them in to instantly outdated charts that
are too boring to look at closely.  This is called "planning".
				(Scott Adams - The Dilbert principle)

 /// 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    ///