diff options
-rw-r--r-- | src/dwb.c | 12 | ||||
-rw-r--r-- | src/dwb.h | 2 | ||||
-rw-r--r-- | src/scripts.c | 8 |
3 files changed, 16 insertions, 6 deletions
@@ -596,7 +596,7 @@ dwb_set_normal_message(GList *gl, gboolean hide, const char *text, ...) if (gl != dwb.state.fview) return; - char message[STRING_LENGTH]; + char message[STRING_LENGTH] = {0}; va_list arg_list; va_start(arg_list, text); @@ -2320,9 +2320,10 @@ dwb_confirm(GList *gl, char *prompt, ...) }/*}}}*/ /* dwb_prompt {{{*/ -const char * +char * dwb_prompt(gboolean visibility, char *prompt, ...) { + char *result = NULL; dwb.state.mode |= CONFIRM; va_list arg_list; char message[STRING_LENGTH]; @@ -2351,8 +2352,13 @@ dwb_prompt(gboolean visibility, char *prompt, ...) dwb_focus_scroll(dwb.state.fview); CLEAR_COMMAND_TEXT(); + + if (state == 0) + result = g_strdup(GET_TEXT()); + + gtk_editable_delete_text(GTK_EDITABLE(dwb.gui.entry), 0, -1); gtk_entry_set_visibility(GTK_ENTRY(dwb.gui.entry), true); - return state == 0 ? GET_TEXT() : NULL; + return result; }/*}}}*/ /* dwb_save_quickmark(const char *key) {{{*/ @@ -968,7 +968,7 @@ void dwb_init_vars(void); void dwb_parse_commands(const char *line); DwbStatus dwb_scheme_handler(GList *gl, WebKitNetworkRequest *request); GList *dwb_get_simple_list(GList *, const char *filename); -const char * dwb_prompt(gboolean visibility, char *prompt, ...); +char * dwb_prompt(gboolean visibility, char *prompt, ...); gboolean dwb_dom_remove_from_parent(WebKitDOMNode *node, GError **error); char * dwb_get_raw_data(GList *gl); diff --git a/src/scripts.c b/src/scripts.c index 1d009110..9071634a 100644 --- a/src/scripts.c +++ b/src/scripts.c @@ -1716,13 +1716,17 @@ io_prompt(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t if (argc > 1 && JSValueIsBoolean(ctx, argv[1])) visibility = JSValueToBoolean(ctx, argv[1]); - const char *response = dwb_prompt(visibility, prompt); + char *response = dwb_prompt(visibility, prompt); g_free(prompt); if (response == NULL) return NIL; - return js_char_to_value(ctx, response); + JSValueRef result = js_char_to_value(ctx, response); + + memset(response, 0, strlen(response)); + g_free(response); + return result; }/*}}}*/ /* io_read {{{*/ |