File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
lib/rex/post/sql/ui/console Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -80,13 +80,25 @@ def _multiline
80
80
81
81
finished = false
82
82
begin
83
+ result = nil
83
84
prompt_proc_before = ::Reline . prompt_proc
84
85
::Reline . prompt_proc = proc { |line_buffer | line_buffer . each_with_index . map { |_line , i | i > 0 ? 'SQL *> ' : 'SQL >> ' } }
85
86
86
87
# We want to do this in a loop
88
+ # multiline_input is the whole string that the user has input, not just the current line.
87
89
raw_query = ::Reline . readmultiline ( 'SQL >> ' , use_history = true ) do |multiline_input |
88
90
# The user pressed ctrl + c or ctrl + z and wants to background our SQL prompt
89
- return { status : :exit , result : nil } unless self . interacting
91
+ unless self . interacting
92
+ result = { status : :exit , result : nil }
93
+ next true
94
+ end
95
+
96
+ # When the user has pressed the enter key with no input, don't run any queries;
97
+ # simply give them a new prompt on a new line.
98
+ if multiline_input . chomp . empty?
99
+ result = { status : :success , result : nil }
100
+ next true
101
+ end
90
102
91
103
# In the case only a stop word was input, exit out of the REPL shell
92
104
finished = ( multiline_input . split . count == 1 && stop_words . include? ( multiline_input . split . last ) )
@@ -99,6 +111,10 @@ def _multiline
99
111
::Reline . prompt_proc = prompt_proc_before
100
112
end
101
113
114
+ if result
115
+ return result
116
+ end
117
+
102
118
if finished
103
119
self . interacting = false
104
120
print_status 'Exiting Shell mode.'
You can’t perform that action at this time.
0 commit comments