mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-27 08:50:02 +03:00
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
This commit is contained in:
parent
ec868fdcdc
commit
2d3b9e435b
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user