Handle hubbub errors.

Handle parser binding errors.

svn path=/trunk/netsurf/; revision=7087
This commit is contained in:
John Mark Bell 2009-04-15 11:28:07 +00:00
parent 4044c864e1
commit 33619d7003
2 changed files with 27 additions and 6 deletions

View File

@ -188,6 +188,13 @@ bool html_process_data(struct content *c, char *data, unsigned int size)
(uint8_t *) data + x, CHUNK);
if (err == BINDING_ENCODINGCHANGE) {
goto encoding_change;
} else if (err != BINDING_OK) {
union content_msg_data msg_data;
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return false;
}
gui_multitask();
@ -197,6 +204,13 @@ bool html_process_data(struct content *c, char *data, unsigned int size)
(uint8_t *) data + x, (size - x));
if (err == BINDING_ENCODINGCHANGE) {
goto encoding_change;
} else if (err != BINDING_OK) {
union content_msg_data msg_data;
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return false;
}
return true;
@ -279,6 +293,7 @@ encoding_change:
bool html_convert(struct content *c, int width, int height)
{
binding_error err;
xmlNode *html, *head;
union content_msg_data msg_data;
unsigned int time_before, time_taken;
@ -288,8 +303,6 @@ bool html_convert(struct content *c, int width, int height)
/* finish parsing */
if (c->source_size == 0) {
binding_error err;
/* Destroy current binding */
binding_destroy_tree(c->data.html.parser_binding);
@ -321,7 +334,16 @@ bool html_convert(struct content *c, int width, int height)
return false;
}
binding_parse_completed(c->data.html.parser_binding);
err = binding_parse_completed(c->data.html.parser_binding);
if (err != BINDING_OK) {
union content_msg_data msg_data;
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return false;
}
c->data.html.document =
binding_get_document(c->data.html.parser_binding);
/*xmlDebugDumpDocument(stderr, c->data.html.document);*/

View File

@ -213,7 +213,7 @@ binding_error binding_parse_chunk(void *ctx, const uint8_t *data, size_t len)
if (err == HUBBUB_ENCODINGCHANGE)
return BINDING_ENCODINGCHANGE;
return BINDING_OK;
return err == HUBBUB_NOMEM ? BINDING_NOMEM : BINDING_OK;
}
binding_error binding_parse_completed(void *ctx)
@ -222,9 +222,8 @@ binding_error binding_parse_completed(void *ctx)
hubbub_error error;
error = hubbub_parser_completed(c->parser);
/** \todo error handling */
return BINDING_OK;
return error == HUBBUB_NOMEM ? BINDING_NOMEM : BINDING_OK;
}
const char *binding_get_encoding(void *ctx, binding_encoding_source *source)