summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/fetch.c16
-rw-r--r--desktop/browser.c1
-rw-r--r--render/box.c17
-rw-r--r--render/form.c19
-rw-r--r--render/form.h4
-rw-r--r--riscos/htmlredraw.c1
6 files changed, 49 insertions, 9 deletions
diff --git a/content/fetch.c b/content/fetch.c
index a191a821c..d42489694 100644
--- a/content/fetch.c
+++ b/content/fetch.c
@@ -678,10 +678,18 @@ struct HttpPost *fetch_post_convert(struct form_successful_control *control)
struct HttpPost *post = 0, *last = 0;
for (; control; control = control->next) {
- curl_formadd(&post, &last,
- CURLFORM_COPYNAME, control->name,
- CURLFORM_COPYCONTENTS, control->value,
- CURLFORM_END);
+ if (control->file) {
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, control->name,
+ CURLFORM_FILE, control->value,
+ CURLFORM_END);
+ }
+ else {
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, control->name,
+ CURLFORM_COPYCONTENTS, control->value,
+ CURLFORM_END);
+ }
}
return post;
diff --git a/desktop/browser.c b/desktop/browser.c
index 337d6f0df..3b9294ade 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -654,6 +654,7 @@ int browser_window_gadget_click(struct browser_window* bw, unsigned long click_x
break;
case GADGET_TEXTBOX:
case GADGET_PASSWORD:
+ case GADGET_FILE:
browser_window_input_click(bw,
(unsigned int)click_boxes[i].actual_x,
(unsigned int)click_boxes[i].actual_y,
diff --git a/render/box.c b/render/box.c
index 94419c4f8..d694481a1 100644
--- a/render/box.c
+++ b/render/box.c
@@ -74,7 +74,7 @@ static struct result box_select(xmlNode *n, struct status *status,
static struct result box_input(xmlNode *n, struct status *status,
struct css_style *style);
static struct box *box_input_text(xmlNode *n, struct status *status,
- struct css_style *style, bool password);
+ struct css_style *style, bool password, bool file);
static struct result box_button(xmlNode *n, struct status *status,
struct css_style *style);
static void add_option(xmlNode* n, struct form_control* current_select, char *text);
@@ -1036,16 +1036,22 @@ struct result box_input(xmlNode *n, struct status *status,
/* the default type is "text" */
if (type == 0 || stricmp(type, "text") == 0)
{
- box = box_input_text(n, status, style, false);
+ box = box_input_text(n, status, style, false, false);
gadget = box->gadget;
gadget->box = box;
}
else if (stricmp(type, "password") == 0)
{
- box = box_input_text(n, status, style, true);
+ box = box_input_text(n, status, style, true, false);
gadget = box->gadget;
gadget->box = box;
}
+ else if (stricmp(type, "file") == 0)
+ {
+ box = box_input_text(n, status, style, false, true);
+ gadget = box->gadget;
+ gadget->box = box;
+ }
else if (stricmp(type, "hidden") == 0)
{
/* no box for hidden inputs */
@@ -1154,7 +1160,7 @@ struct result box_input(xmlNode *n, struct status *status,
}
struct box *box_input_text(xmlNode *n, struct status *status,
- struct css_style *style, bool password)
+ struct css_style *style, bool password, bool file)
{
char *s;
unsigned int i;
@@ -1191,6 +1197,9 @@ struct box *box_input_text(xmlNode *n, struct status *status,
inline_box->text = xcalloc(inline_box->length + 1, 1);
for (i = 0; i != inline_box->length; i++)
inline_box->text[i] = '*';
+ } else if (file) {
+ box->gadget->type = GADGET_FILE;
+ inline_box->text = xcalloc(inline_box->length + 1, 1);
} else {
box->gadget->type = GADGET_TEXTBOX;
inline_box->text = xstrdup(box->gadget->value);
diff --git a/render/form.c b/render/form.c
index 6eee708b2..145ef68bd 100644
--- a/render/form.c
+++ b/render/form.c
@@ -11,10 +11,12 @@
*/
#include <assert.h>
+#include <stdio.h>
#include <string.h>
#include "curl/curl.h"
#include "netsurf/render/box.h"
#include "netsurf/render/form.h"
+#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
@@ -79,6 +81,7 @@ struct form_successful_control *form_successful_controls(struct form *form,
option = option->next) {
if (option->selected) {
success_new = xcalloc(1, sizeof(*success_new));
+ success_new->file = false;
success_new->name = xstrdup(control->name);
success_new->value = xstrdup(option->value);
success_new->next = 0;
@@ -92,6 +95,7 @@ struct form_successful_control *form_successful_controls(struct form *form,
/* textarea */
if (control->type == GADGET_TEXTAREA) {
success_new = xcalloc(1, sizeof(*success_new));
+ success_new->file = false;
success_new->name = xstrdup(control->name);
success_new->value = form_textarea_value(control);
success_new->next = 0;
@@ -105,6 +109,7 @@ struct form_successful_control *form_successful_controls(struct form *form,
unsigned int len = strlen(control->name) + 3;
/* x */
success_new = xcalloc(1, sizeof(*success_new));
+ success_new->file = false;
success_new->name = xcalloc(1, len);
sprintf(success_new->name, "%s.x", control->name);
success_new->value = xcalloc(1, 20);
@@ -114,6 +119,7 @@ struct form_successful_control *form_successful_controls(struct form *form,
last_success = success_new;
/* y */
success_new = xcalloc(1, sizeof(*success_new));
+ success_new->file = false;
success_new->name = xcalloc(1, len);
sprintf(success_new->name, "%s.y", control->name);
success_new->value = xcalloc(1, 20);
@@ -127,9 +133,22 @@ struct form_successful_control *form_successful_controls(struct form *form,
if (control->type == GADGET_RESET)
continue;
+ /* file */
+ if (control->type == GADGET_FILE) {
+ success_new = xcalloc(1, sizeof(*success_new));
+ success_new->file = true;
+ success_new->name = xstrdup(control->name);
+ success_new->value = xstrdup(control->value);
+ success_new->next = 0;
+ last_success->next = success_new;
+ last_success = success_new;
+ continue;
+ }
+
/* all others added if they have a value */
if (control->value) {
success_new = xcalloc(1, sizeof(*success_new));
+ success_new->file = false;
success_new->name = xstrdup(control->name);
success_new->value = xstrdup(control->value);
success_new->next = 0;
diff --git a/render/form.h b/render/form.h
index 53f933720..0063df790 100644
--- a/render/form.h
+++ b/render/form.h
@@ -36,7 +36,8 @@ struct form {
struct form_control {
enum { GADGET_HIDDEN, GADGET_TEXTBOX, GADGET_RADIO, GADGET_CHECKBOX,
GADGET_SELECT, GADGET_TEXTAREA, GADGET_IMAGE,
- GADGET_PASSWORD, GADGET_SUBMIT, GADGET_RESET } type;
+ GADGET_PASSWORD, GADGET_SUBMIT, GADGET_RESET,
+ GADGET_FILE } type;
char *name;
char *value;
char *initial_value;
@@ -80,6 +81,7 @@ struct form_option {
/** Successful control, as defined by HTML 4.01 17.13. */
struct form_successful_control {
+ bool file; /**< It's a file */
char *name; /**< Control name. */
char *value; /**< Current value. */
struct form_successful_control *next; /**< Next in linked list. */
diff --git a/riscos/htmlredraw.c b/riscos/htmlredraw.c
index d4e2f0e16..e5d76ef4b 100644
--- a/riscos/htmlredraw.c
+++ b/riscos/htmlredraw.c
@@ -196,6 +196,7 @@ void html_redraw_box(struct content *content, struct box * box,
case GADGET_PASSWORD:
case GADGET_SUBMIT:
case GADGET_RESET:
+ case GADGET_FILE:
break;
}