From 3a5d7d6b644fe3dbea04bf9803f7b712832a10a4 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 20 Nov 2008 14:47:36 +0000 Subject: Process error page correctly. TODO: Why don't *_process_data take a const pointer to the data? svn path=/trunk/netsurf/; revision=5757 --- render/html.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'render/html.c') diff --git a/render/html.c b/render/html.c index 355885b1d..804bdd7c1 100644 --- a/render/html.c +++ b/render/html.c @@ -254,9 +254,37 @@ bool html_convert(struct content *c, int width, int height) /* finish parsing */ if (c->source_size == 0) { - binding_parse_chunk(c->data.html.parser_binding, - (uint8_t *) empty_document, - sizeof empty_document); + binding_error err; + + /* Destroy current binding */ + binding_destroy_tree(c->data.html.parser_binding); + + /* Also, any existing encoding information, + * as it's not guaranteed to match the error page. + */ + free(c->data.html.encoding); + c->data.html.encoding = NULL; + + /* Create new binding, using default charset */ + err = binding_create_tree(c, NULL, + &c->data.html.parser_binding); + if (err != BINDING_OK) { + union content_msg_data msg_data; + + if (err == BINDING_BADENCODING) { + LOG(("Bad encoding: %s", c->data.html.encoding + ? c->data.html.encoding : "")); + msg_data.error = messages_get("ParsingFail"); + } else + msg_data.error = messages_get("NoMemory"); + content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + return false; + } + + /* Process the error page */ + if (html_process_data(c, (char *) empty_document, + SLEN(empty_document)) == false) + return false; } binding_parse_completed(c->data.html.parser_binding); -- cgit v1.2.3