summaryrefslogtreecommitdiff
path: root/render/html.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-02-20 12:50:34 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-02-20 12:50:34 +0000
commit1f859400d962270ba418530e3a147004b4545963 (patch)
tree48a05d744ce6c778b80d60e2012333fbb13317ee /render/html.c
parent8bebcb5ca9d2760ff410a4c415a4f599ba9128fc (diff)
downloadnetsurf-1f859400d962270ba418530e3a147004b4545963.tar.gz
netsurf-1f859400d962270ba418530e3a147004b4545963.tar.bz2
If we have no document charset on completion of parse, retrieve it from the binding.
Make the binding return Windows-1252 if it has no idea (as this is what the parser will have defaulted to). Fix form_new to not require a document charset to be present -- it may not be known at this point. Fixup form document charsets post-parse, so that form submission works correctly. svn path=/trunk/netsurf/; revision=6575
Diffstat (limited to 'render/html.c')
-rw-r--r--render/html.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/render/html.c b/render/html.c
index 91f55b145..6887bdc80 100644
--- a/render/html.c
+++ b/render/html.c
@@ -333,6 +333,19 @@ bool html_convert(struct content *c, int width, int height)
return false;
}
+ if (c->data.html.encoding == NULL) {
+ const char *encoding = binding_get_encoding(
+ c->data.html.parser_binding,
+ &c->data.html.encoding_source);
+
+ c->data.html.encoding = talloc_strdup(c, encoding);
+ if (c->data.html.encoding == NULL) {
+ msg_data.error = messages_get("NoMemory");
+ content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ return false;
+ }
+ }
+
/* locate html and head elements */
html = xmlDocGetRootElement(c->data.html.document);
if (html == 0 || strcmp((const char *) html->name, "html") != 0) {
@@ -369,11 +382,11 @@ bool html_convert(struct content *c, int width, int height)
#ifdef WITH_HUBBUB
/* Retrieve forms from parser */
c->data.html.forms = binding_get_forms(c->data.html.parser_binding);
- /* Make all actions absolute */
for (f = c->data.html.forms; f != NULL; f = f->prev) {
char *action;
url_func_result res;
+ /* Make all actions absolute */
res = url_join(f->action, c->data.html.base_url, &action);
if (res != URL_FUNC_OK) {
msg_data.error = messages_get("NoMemory");
@@ -383,6 +396,17 @@ bool html_convert(struct content *c, int width, int height)
free(f->action);
f->action = action;
+
+ /* Ensure each form has a document encoding */
+ if (f->document_charset == NULL) {
+ f->document_charset = strdup(c->data.html.encoding);
+ if (f->document_charset == NULL) {
+ msg_data.error = messages_get("NoMemory");
+ content_broadcast(c, CONTENT_MSG_ERROR,
+ msg_data);
+ return false;
+ }
+ }
}
#endif