diff --git a/libmproxy/console/common.py b/libmproxy/console/common.py index 185480db2..e4ecde916 100644 --- a/libmproxy/console/common.py +++ b/libmproxy/console/common.py @@ -203,7 +203,7 @@ def save_data(path, data, master, state): def ask_save_path(prompt, data, master, state): - signals.status_path_prompt.send( + signals.status_prompt_path.send( prompt = prompt, text = state.last_saveload, callback = save_data, @@ -260,7 +260,7 @@ def copy_flow(part, scope, flow, master, state): except RuntimeError: def save(k): if k == "y": - ask_save_path("Save data: ", data, master, state) + ask_save_path("Save data", data, master, state) signals.status_prompt_onekey.send( prompt = "Cannot copy binary data to clipboard. Save as file?", keys = ( @@ -316,14 +316,14 @@ def ask_save_body(part, master, state, flow): elif part == "q" and request_has_content: ask_save_path( - "Save request content: ", + "Save request content", flow.request.get_decoded_content(), master, state ) elif part == "s" and response_has_content: ask_save_path( - "Save response content: ", + "Save response content", flow.response.get_decoded_content(), master, state diff --git a/libmproxy/console/flowlist.py b/libmproxy/console/flowlist.py index d4dd89d88..f39188bb7 100644 --- a/libmproxy/console/flowlist.py +++ b/libmproxy/console/flowlist.py @@ -111,14 +111,14 @@ class ConnectionItem(urwid.WidgetWrap): def save_flows_prompt(self, k): if k == "a": - signals.status_path_prompt.send( - prompt = "Save all flows to: ", + signals.status_prompt_path.send( + prompt = "Save all flows to", text = self.state.last_saveload, callback = self.master.save_flows ) else: - signals.status_path_prompt.send( - prompt = "Save this flow to: ", + signals.status_prompt_path.send( + prompt = "Save this flow to", text = self.state.last_saveload, callback = self.master.save_one_flow, args = (self.flow,) @@ -150,8 +150,8 @@ class ConnectionItem(urwid.WidgetWrap): self.master.options.replay_ignore_host ) else: - signals.status_path_prompt.send( - prompt = "Server replay path: ", + signals.status_prompt_path.send( + prompt = "Server replay path", text = self.state.last_saveload, callback = self.master.server_playback_path ) @@ -216,8 +216,8 @@ class ConnectionItem(urwid.WidgetWrap): if self.flow.request: self.master.view_flow(self.flow) elif key == "|": - signals.status_path_prompt.send( - prompt = "Send flow to script: ", + signals.status_prompt_path.send( + prompt = "Send flow to script", text = self.state.last_script, callback = self.master.run_script_once, args = (self.flow,) @@ -269,7 +269,7 @@ class FlowListBox(urwid.ListBox): if k == "e": signals.status_prompt.send( self, - prompt = "Method:", + prompt = "Method", text = "", callback = self.get_method_raw ) @@ -282,7 +282,7 @@ class FlowListBox(urwid.ListBox): def get_url(self, method): signals.status_prompt.send( - prompt = "URL:", + prompt = "URL", text = "http://www.example.com/", callback = self.new_request, args = (method,) @@ -308,14 +308,14 @@ class FlowListBox(urwid.ListBox): self.master.toggle_eventlog() elif key == "l": signals.status_prompt.send( - prompt = "Limit: ", + prompt = "Limit", text = self.master.state.limit_txt, callback = self.master.set_limit ) elif key == "L": - signals.status_path_prompt.send( + signals.status_prompt_path.send( self, - prompt = "Load flows: ", + prompt = "Load flows", text = self.master.state.last_saveload, callback = self.master.load_flows_callback ) @@ -331,9 +331,9 @@ class FlowListBox(urwid.ListBox): if self.master.stream: self.master.stop_stream() else: - signals.status_path_prompt.send( + signals.status_prompt_path.send( self, - prompt = "Stream flows to: ", + prompt = "Stream flows to", text = self.master.state.last_saveload, callback = self.master.start_stream_to_path ) diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py index 941ceb942..b9d5fbcac 100644 --- a/libmproxy/console/flowview.py +++ b/libmproxy/console/flowview.py @@ -493,7 +493,7 @@ class FlowView(urwid.WidgetWrap): def edit_method(self, m): if m == "e": signals.status_prompt.send( - prompt = "Method: ", + prompt = "Method", text = self.flow.request.method, callback = self.set_method_raw ) @@ -592,7 +592,7 @@ class FlowView(urwid.WidgetWrap): self.master.view_grideditor(grideditor.QueryEditor(self.master, message.get_query().lst, self.set_query, message)) elif part == "u" and self.state.view_flow_mode == common.VIEW_FLOW_REQUEST: signals.status_prompt.send( - prompt = "URL: ", + prompt = "URL", text = message.url, callback = self.set_url ) @@ -604,13 +604,13 @@ class FlowView(urwid.WidgetWrap): ) elif part == "c" and self.state.view_flow_mode == common.VIEW_FLOW_RESPONSE: signals.status_prompt.send( - prompt = "Code: ", + prompt = "Code", text = str(message.code), callback = self.set_resp_code ) elif part == "m" and self.state.view_flow_mode == common.VIEW_FLOW_RESPONSE: signals.status_prompt.send( - prompt = "Message: ", + prompt = "Message", text = message.msg, callback = self.set_resp_msg ) @@ -769,8 +769,8 @@ class FlowView(urwid.WidgetWrap): self.master.refresh_flow(self.flow) signals.status_message.send(message="Reverted.") elif key == "W": - signals.status_path_prompt.send( - prompt = "Save this flow: ", + signals.status_prompt_path.send( + prompt = "Save this flow", text = self.state.last_saveload, callback = self.master.save_one_flow, args = (self.flow,) @@ -784,8 +784,8 @@ class FlowView(urwid.WidgetWrap): else: signals.status_message.send(message="Error! Set $EDITOR or $PAGER.") elif key == "|": - signals.status_path_prompt.send( - prompt = "Send flow to script: ", + signals.status_prompt_path.send( + prompt = "Send flow to script", text = self.state.last_script, callback = self.master.run_script_once, args = (self.flow,) @@ -822,7 +822,7 @@ class FlowView(urwid.WidgetWrap): self.master.refresh_flow(self.flow) elif key == "/": last_search_string = self.state.get_flow_setting(self.flow, "last_search_string") - search_prompt = "Search body ["+last_search_string+"]: " if last_search_string else "Search body: " + search_prompt = "Search body ["+last_search_string+"]" if last_search_string else "Search body" signals.status_prompt.send( prompt = search_prompt, text = "", diff --git a/libmproxy/console/grideditor.py b/libmproxy/console/grideditor.py index eb66e59e8..e7c9854be 100644 --- a/libmproxy/console/grideditor.py +++ b/libmproxy/console/grideditor.py @@ -338,17 +338,17 @@ class GridEditor(urwid.WidgetWrap): self.walker.delete_focus() elif key == "r": if self.walker.get_current_value() is not None: - signals.status_path_prompt.send( + signals.status_prompt_path.send( self, - prompt = "Read file: ", + prompt = "Read file", text = "", callback = self.read_file ) elif key == "R": if self.walker.get_current_value() is not None: - signals.status_path_prompt.send( + signals.status_prompt_path.send( self, - prompt = "Read unescaped file: ", + prompt = "Read unescaped file", text = "", callback = self.read_file, args = (True,) diff --git a/libmproxy/console/signals.py b/libmproxy/console/signals.py index 8fb35cff9..e8944afb6 100644 --- a/libmproxy/console/signals.py +++ b/libmproxy/console/signals.py @@ -7,7 +7,7 @@ status_message = blinker.Signal() status_prompt = blinker.Signal() # Prompt for a path -status_path_prompt = blinker.Signal() +status_prompt_path = blinker.Signal() # Prompt for a single keystroke status_prompt_onekey = blinker.Signal() diff --git a/libmproxy/console/statusbar.py b/libmproxy/console/statusbar.py index c1a907bdc..7ff26b155 100644 --- a/libmproxy/console/statusbar.py +++ b/libmproxy/console/statusbar.py @@ -12,7 +12,7 @@ class ActionBar(urwid.WidgetWrap): self.clear() signals.status_message.connect(self.sig_message) signals.status_prompt.connect(self.sig_prompt) - signals.status_path_prompt.connect(self.sig_path_prompt) + signals.status_prompt_path.connect(self.sig_path_prompt) signals.status_prompt_onekey.connect(self.sig_prompt_onekey) self.prompting = False @@ -27,14 +27,17 @@ class ActionBar(urwid.WidgetWrap): self.clear() signals.call_in.send(seconds=expire, callback=cb) + def prep_prompt(self, p): + return p.strip() + ": " + def sig_prompt(self, sender, prompt, text, callback, args=()): signals.focus.send(self, section="footer") - self._w = urwid.Edit(prompt, text or "") + self._w = urwid.Edit(self.prep_prompt(prompt), text or "") self.prompting = (callback, args) def sig_path_prompt(self, sender, prompt, text, callback, args=()): signals.focus.send(self, section="footer") - self._w = pathedit.PathEdit(prompt, text) + self._w = pathedit.PathEdit(self.prep_prompt(prompt), text) self.prompting = (callback, args) def sig_prompt_onekey(self, sender, prompt, keys, callback, args=()): @@ -230,12 +233,3 @@ class StatusBar(urwid.WidgetWrap): def selectable(self): return True - - def get_edit_text(self): - return self.ab._w.get_edit_text() - - def path_prompt(self, prompt, text): - return self.ab.path_prompt(prompt, text) - - def prompt(self, prompt, text = ""): - self.ab.prompt(prompt, text) diff --git a/libmproxy/console/window.py b/libmproxy/console/window.py index 55145c481..87f06637a 100644 --- a/libmproxy/console/window.py +++ b/libmproxy/console/window.py @@ -16,9 +16,9 @@ class Window(urwid.Frame): self.master.view_help() elif k == "c": if not self.master.client_playback: - signals.status_path_prompt.send( + signals.status_prompt_path.send( self, - prompt = "Client replay: ", + prompt = "Client replay", text = self.master.state.last_saveload, callback = self.master.client_playback_path ) @@ -59,7 +59,7 @@ class Window(urwid.Frame): elif k == "i": signals.status_prompt.send( self, - prompt = "Intercept filter: ", + prompt = "Intercept filter", text = self.master.state.intercept_txt, callback = self.master.set_intercept ) @@ -99,9 +99,9 @@ class Window(urwid.Frame): ) elif k == "S": if not self.master.server_playback: - signals.status_path_prompt.send( + signals.status_prompt_path.send( self, - prompt = "Server replay path: ", + prompt = "Server replay path", text = self.master.state.last_saveload, callback = self.master.server_playback_path ) @@ -130,13 +130,13 @@ class Window(urwid.Frame): ) elif k == "t": signals.status_prompt.send( - prompt = "Sticky cookie filter: ", + prompt = "Sticky cookie filter", text = self.master.stickycookie_txt, callback = self.master.set_stickycookie ) elif k == "u": signals.status_prompt.send( - prompt = "Sticky auth filter: ", + prompt = "Sticky auth filter", text = self.master.stickyauth_txt, callback = self.master.set_stickyauth )