From 6d39b569c700ddfa405c5c9a7a49320be2945997 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Fri, 17 Aug 2012 20:26:00 +0100 Subject: Pass content containing form's nsurl to form_submit, instead of its hlcache_handle. Avoid dereferencing bw in html content handlers. --- render/form.c | 13 +++++-------- render/form.h | 2 +- render/html_interaction.c | 2 +- render/textinput.c | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/render/form.c b/render/form.c index 40e95ea31..09579dc5b 100644 --- a/render/form.c +++ b/render/form.c @@ -1460,7 +1460,7 @@ void form_radio_set(hlcache_handle *content, * Collect controls and submit a form. */ -void form_submit(hlcache_handle *h, struct browser_window *target, +void form_submit(nsurl *page_url, struct browser_window *target, struct form *form, struct form_control *submit_button) { char *data = NULL, *url = NULL; @@ -1507,8 +1507,7 @@ void form_submit(hlcache_handle *h, struct browser_window *target, url_destroy_components(&components); - browser_window_go(target, url, nsurl_access(hlcache_handle_get_url(h)), - true); + browser_window_go(target, url, nsurl_access(page_url), true); break; case method_POST_URLENC: @@ -1520,14 +1519,12 @@ void form_submit(hlcache_handle *h, struct browser_window *target, } browser_window_go_post(target, form->action, data, 0, - true, nsurl_access(hlcache_handle_get_url(h)), - false, true, 0); + true, nsurl_access(page_url), false, true, 0); break; case method_POST_MULTIPART: - browser_window_go_post(target, form->action, 0, - success, true, nsurl_access(hlcache_handle_get_url(h)), - false, true, 0); + browser_window_go_post(target, form->action, 0, success, + true, nsurl_access(page_url), false, true, 0); break; } diff --git a/render/form.h b/render/form.h index e2f9f63b6..dab6a625d 100644 --- a/render/form.h +++ b/render/form.h @@ -173,7 +173,7 @@ void form_select_get_dimensions(struct form_control *control, int *width, int *height); void form_select_process_selection(hlcache_handle *h, struct form_control *control, int item); -void form_submit(struct hlcache_handle *h, struct browser_window *target, +void form_submit(nsurl *page_url, struct browser_window *target, struct form *form, struct form_control *submit_button); void form_radio_set(struct hlcache_handle *content, struct form_control *radio); diff --git a/render/html_interaction.c b/render/html_interaction.c index 1365d77e0..4d21b222c 100644 --- a/render/html_interaction.c +++ b/render/html_interaction.c @@ -839,7 +839,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw, */ switch (action) { case ACTION_SUBMIT: - form_submit(bw->current_content, + form_submit(content_get_url(c), browser_window_find_target(bw, target, mouse), gadget->form, gadget); break; diff --git a/render/textinput.c b/render/textinput.c index 3c3eb7361..6c580a8cd 100644 --- a/render/textinput.c +++ b/render/textinput.c @@ -1911,7 +1911,7 @@ bool textinput_input_callback(struct browser_window *bw, uint32_t key, selection_clear(&html->sel, true); if (form) - form_submit(bw->current_content, bw, form, 0); + form_submit(content_get_url(c), bw, form, 0); return true; case KEY_SHIFT_TAB: -- cgit v1.2.3