From 28f974f00f43d3a04c0bcae32e7cfc85ee66df20 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Sat, 25 Oct 2003 14:13:49 +0000 Subject: [project @ 2003-10-25 14:13:49 by bursa] URL encoded POST support. svn path=/import/netsurf/; revision=375 --- render/box.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'render/box.c') 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 #include #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, -- cgit v1.2.3