summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-01-06 22:06:14 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-01-06 22:06:14 +0000
commit2d3b9e435bb3a8294316fe7b10907cb608f10241 (patch)
tree28912650b870d6101639e4a1fc73edef3787e187 /render
parentec868fdcdc7fefe7cb9dbb69380eb73d6742a383 (diff)
downloadnetsurf-2d3b9e435bb3a8294316fe7b10907cb608f10241.tar.gz
netsurf-2d3b9e435bb3a8294316fe7b10907cb608f10241.tar.bz2
Charset fallbacks. If we don't support the charset declared in the HTTP header, fall back to autodetect. If we don't support the charset declared in a meta charset, fall back to Windows-1252.
svn path=/trunk/netsurf/; revision=5974
Diffstat (limited to 'render')
-rw-r--r--render/html.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/render/html.c b/render/html.c
index 047cd9114..70ee5ccb3 100644
--- a/render/html.c
+++ b/render/html.c
@@ -143,6 +143,16 @@ bool html_create(struct content *c, const char *params[])
/* Create the parser binding */
error = binding_create_tree(c, html->encoding, &html->parser_binding);
+ if (error == BINDING_BADENCODING && html->encoding != NULL) {
+ /* Ok, we don't support the declared encoding. Bailing out
+ * isn't exactly user-friendly, so fall back to autodetect */
+ talloc_free(html->encoding);
+ html->encoding = NULL;
+
+ error = binding_create_tree(c, html->encoding,
+ &html->parser_binding);
+ }
+
if (error != BINDING_OK)
goto error;
@@ -215,6 +225,23 @@ encoding_change:
/* Create new binding, using the new encoding */
err = binding_create_tree(c, c->data.html.encoding,
&c->data.html.parser_binding);
+ if (err == BINDING_BADENCODING) {
+ /* Ok, we don't support the declared encoding. Bailing out
+ * isn't exactly user-friendly, so fall back to Windows-1252 */
+ talloc_free(c->data.html.encoding);
+ c->data.html.encoding = talloc_strdup(c, "Windows-1252");
+ if (c->data.html.encoding == NULL) {
+ union content_msg_data msg_data;
+
+ msg_data.error = messages_get("NoMemory");
+ content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ return false;
+ }
+
+ err = binding_create_tree(c, c->data.html.encoding,
+ &c->data.html.parser_binding);
+ }
+
if (err != BINDING_OK) {
union content_msg_data msg_data;