summaryrefslogtreecommitdiff
path: root/render/box_construct.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2005-04-16 05:09:33 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2005-04-16 05:09:33 +0000
commitc17dc661eae89cea66959fad4fe48d77f1faf174 (patch)
tree1909b4157137e66b3f74adc75ca1a2bbf3bc3c6f /render/box_construct.c
parent37a4119ab80b1a7c7e37707c4e029218bdcbe549 (diff)
downloadnetsurf-c17dc661eae89cea66959fad4fe48d77f1faf174.tar.gz
netsurf-c17dc661eae89cea66959fad4fe48d77f1faf174.tar.bz2
[project @ 2005-04-16 05:09:32 by jmb]
Split out UTF-8 handling functions. Submit URL-encoded forms in sensible encoding: * First entry in accept-charset list, if present * Document encoding, otherwise We may want to explicitly look for UTF-8, to save converting. Convert cnv_str_local_enc/cnv_local_enc_str to use iconv (they're now veneers for utf8_[to/from]_enc). Provide mechanism for looking up local system charset (derived from system alphabet, under RISC OS) svn path=/import/netsurf/; revision=1647
Diffstat (limited to 'render/box_construct.c')
-rw-r--r--render/box_construct.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/render/box_construct.c b/render/box_construct.c
index 9723b4de1..88a432e67 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -1575,7 +1575,7 @@ bool box_iframe(BOX_SPECIAL_PARAMS)
bool box_form(BOX_SPECIAL_PARAMS)
{
- char *action, *method, *enctype;
+ char *action, *method, *enctype, *charset;
form_method fmethod;
struct form *form;
@@ -1598,9 +1598,35 @@ bool box_form(BOX_SPECIAL_PARAMS)
xmlFree(method);
}
- form = form_new(action, fmethod);
+ /* acceptable encoding(s) for form data */
+ if ((charset = (char *) xmlGetProp(n, (const xmlChar *) "accept-charset"))) {
+ char *comma = strchr(charset, ',');
+ if (!comma)
+ /* only one => use it */
+ comma = strdup(charset);
+ else
+ /* multiple => use first */
+ comma = strndup(charset, comma - charset);
+
+ xmlFree(charset);
+ charset = comma;
+ }
+ else if (content->data.html.encoding)
+ /* none specified => try document encoding */
+ charset = strdup(content->data.html.encoding);
+ else
+ /* none specified and no document encoding => 8859-1 */
+ charset = strdup("ISO-8859-1");
+
+ if (!charset) {
+ xmlFree(action);
+ return false;
+ }
+
+ form = form_new(action, fmethod, charset);
if (!form) {
xmlFree(action);
+ free(charset);
return false;
}
form->prev = content->data.html.forms;