File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,9 @@ namespace Terminal.Utils {
136
136
*/
137
137
public bool is_safe_paste (string text , out string []? msg_array ) {
138
138
string [] msgs = {};
139
- if (" \n " in text || " &" in text || " |" in text || " ;" in text ) {
139
+ var newline_index = text. index_of (" \n " ); // First occurrence of new line
140
+ bool embedded_newline = newline_index >= 0 && newline_index < text. length - 1 ;
141
+ if (embedded_newline || " &" in text || " |" in text || " ;" in text ) {
140
142
msgs + = _(" The pasted text may contain multiple commands" );
141
143
}
142
144
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ private void main (string[] args) {
27
27
assert (! Terminal . Utils . is_safe_paste (" sudo apt autoremove" , out msg_array));
28
28
29
29
// Multi-line commands
30
- assert (! Terminal . Utils . is_safe_paste (" \n " , out msg_array));
30
+ assert (Terminal . Utils . is_safe_paste (" xx\n " , out msg_array));
31
+ assert (! Terminal . Utils . is_safe_paste (" xx\n yy" , out msg_array));
31
32
assert (! Terminal . Utils . is_safe_paste (" &" , out msg_array));
32
33
assert (! Terminal . Utils . is_safe_paste (" |" , out msg_array));
33
34
assert (! Terminal . Utils . is_safe_paste (" ;" , out msg_array));
You can’t perform that action at this time.
0 commit comments