diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c index 609765137..d2701e5b1 100644 --- a/desktop/tree_url_node.c +++ b/desktop/tree_url_node.c @@ -728,15 +728,18 @@ bool tree_urlfile_load(const char *filename, struct tree *tree, dom_document *document; dom_node *html, *body, *ul; struct node *root; + nserror error; tree_url_load_ctx ctx; if (filename == NULL) { return false; } - document = libdom_parse_file(filename, "iso-8859-1"); - if (document == NULL) { - warn_user("TreeLoadError", messages_get("ParsingFail")); + error = libdom_parse_file(filename, "iso-8859-1", &document); + if (error != NSERROR_OK) { + if (error != NSERROR_NOT_FOUND) { + warn_user("TreeLoadError", messages_get("ParsingFail")); + } return false; } diff --git a/utils/libdom.c b/utils/libdom.c index 756465a02..ee911c3ff 100644 --- a/utils/libdom.c +++ b/utils/libdom.c @@ -259,7 +259,7 @@ static void ignore_dom_msg(uint32_t severity, void *ctx, const char *msg, ...) } /* exported interface documented in libdom.h */ -dom_document *libdom_parse_file(const char *filename, const char *encoding) +nserror libdom_parse_file(const char *filename, const char *encoding, dom_document **doc) { dom_hubbub_error error; dom_hubbub_parser *parser; @@ -270,14 +270,14 @@ dom_document *libdom_parse_file(const char *filename, const char *encoding) fp = fopen(filename, "r"); if (fp == NULL) { - return NULL; + return NSERROR_NOT_FOUND; } parser = dom_hubbub_parser_create(encoding, false, false, ignore_dom_msg, NULL, NULL, &document); if (parser == NULL) { fclose(fp); - return NULL; + return NSERROR_DOM; } while (feof(fp) == 0) { @@ -288,7 +288,7 @@ dom_document *libdom_parse_file(const char *filename, const char *encoding) dom_node_unref(document); dom_hubbub_parser_destroy(parser); fclose(fp); - return NULL; + return NSERROR_DOM; } } @@ -297,10 +297,11 @@ dom_document *libdom_parse_file(const char *filename, const char *encoding) dom_node_unref(document); dom_hubbub_parser_destroy(parser); fclose(fp); - return NULL; + return NSERROR_DOM; } dom_hubbub_parser_destroy(parser); - return document; + *doc = document; + return NSERROR_OK; } diff --git a/utils/libdom.h b/utils/libdom.h index f2da40570..d79c92d81 100644 --- a/utils/libdom.h +++ b/utils/libdom.h @@ -62,6 +62,7 @@ typedef bool (*libdom_iterate_cb)(dom_node *node, void *ctx); void libdom_iterate_child_elements(dom_node *parent, libdom_iterate_cb cb, void *ctx); -dom_document *libdom_parse_file(const char *filename, const char *encoding); +nserror libdom_parse_file(const char *filename, const char *encoding, + dom_document **doc); #endif