summaryrefslogtreecommitdiff
path: root/render/box.c
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2003-10-25 14:13:49 +0000
committerJames Bursa <james@netsurf-browser.org>2003-10-25 14:13:49 +0000
commit28f974f00f43d3a04c0bcae32e7cfc85ee66df20 (patch)
tree9ab73b22014e6da29c851698b0f7c0262260cc8e /render/box.c
parentf1375fe19db064fcebf00433ce73eab99be038ef (diff)
downloadnetsurf-28f974f00f43d3a04c0bcae32e7cfc85ee66df20.tar.gz
netsurf-28f974f00f43d3a04c0bcae32e7cfc85ee66df20.tar.bz2
[project @ 2003-10-25 14:13:49 by bursa]
URL encoded POST support. svn path=/import/netsurf/; revision=375
Diffstat (limited to 'render/box.c')
-rw-r--r--render/box.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/render/box.c b/render/box.c
index 3ad80ffad..6e9518931 100644
--- a/render/box.c
+++ b/render/box.c
@@ -14,7 +14,7 @@
#include <stdlib.h>
#include <string.h>
#include "libxml/HTMLparser.h"
-#include "netsurf/content/fetchcache.h"
+#include "netsurf/content/content.h"
#include "netsurf/css/css.h"
#include "netsurf/render/box.h"
#include "netsurf/render/font.h"
@@ -737,22 +737,31 @@ struct result box_image(xmlNode *n, struct status *status,
struct result box_form(xmlNode *n, struct status *status,
struct css_style *style)
{
- char* s;
+ char *s, *s2;
struct box *box;
struct form *form;
box = box_create(style, status->href, status->title);
- status->current_form = form = xcalloc(1, sizeof(*form));
-
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "action"))) {
- form->action = s;
+ s = (char *) xmlGetProp(n, (const xmlChar *) "action");
+ if (!s) {
+ /* the action attribute is required */
+ return (struct result) {box, 1};
}
+ status->current_form = form = xcalloc(1, sizeof(*form));
+ form->action = s;
+
form->method = method_GET;
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "method"))) {
- if (stricmp(s, "post") == 0)
- form->method = method_POST;
+ if (strcasecmp(s, "post") == 0) {
+ form->method = method_POST_URLENC;
+ if ((s2 = (char *) xmlGetProp(n, (const xmlChar *) "enctype"))) {
+ if (strcasecmp(s2, "multipart/form-data") == 0)
+ form->method = method_POST_MULTIPART;
+ xmlFree(s2);
+ }
+ }
xmlFree(s);
}
@@ -913,13 +922,18 @@ void add_option(xmlNode* n, struct form_control* current_select, char *text)
current_select->data.select.last_item->next = option;
current_select->data.select.last_item = option;
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value"))) {
+ option->value = s;
+ } else {
+ option->value = xstrdup(text);
+ }
+
for (c = text; *c; c++)
if (*c == ' ')
*c = 160;
option->selected = option->initial_selected = false;
option->text = text;
- option->value = 0;
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "selected"))) {
xmlFree(s);
@@ -930,10 +944,6 @@ void add_option(xmlNode* n, struct form_control* current_select, char *text)
current_select->data.select.current = option;
}
}
-
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "value"))) {
- option->value = s;
- }
}
struct result box_input(xmlNode *n, struct status *status,