aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2001-01-23 12:37:59 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-01-23 12:37:59 +0800
commit4cf9b5a00cb088a3d40974f48b69120afcaf1b68 (patch)
treeaf8502deb7d160d121e63bb2e5de2b5671f89850 /camel
parent73053088aa1a33486a1bfb9637bf37f8bf984a18 (diff)
downloadgsoc2013-evolution-4cf9b5a00cb088a3d40974f48b69120afcaf1b68.tar.gz
gsoc2013-evolution-4cf9b5a00cb088a3d40974f48b69120afcaf1b68.tar.zst
gsoc2013-evolution-4cf9b5a00cb088a3d40974f48b69120afcaf1b68.zip
Perform error checking on parsing/execution.
2001-01-23 Not Zed <NotZed@Ximian.com> * camel-filter-search.c (camel_filter_search_match): Perform error checking on parsing/execution. * camel-folder-search.c (camel_folder_search_execute_expression): Perform error handling on search expression. (CamelFolderSearchPrivate): Add a camelexception for error returns. (camel_folder_search_execute_expression): Setup exception pointer. (search_match_all): Quit on error. * providers/imap/camel-imap-summary.c (message_info_load): Removed some debug 'warnings', as they should now be displayed at the toplevel loader, and just made the code match similar code elsewhere. * providers/local/camel-mbox-summary.c (message_info_load): Error handling. (message_info_save): more error handling. * camel-folder-summary.c (message_info_load): Add error handling and sanity checking. (camel_folder_summary_load): Add error checks. (perform_content_info_load): Error + sanity checks. (content_info_load): error + sanity checks. svn path=/trunk/; revision=7739
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog12
-rw-r--r--camel/camel-filter-driver.c20
-rw-r--r--camel/camel-filter-search.c19
-rw-r--r--camel/camel-folder-search.c21
4 files changed, 60 insertions, 12 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index ae517c44ab..b83952e691 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,15 @@
2001-01-23 Not Zed <NotZed@Ximian.com>
+ * camel-filter-search.c (camel_filter_search_match): Perform error
+ checking on parsing/execution.
+
+ * camel-folder-search.c (camel_folder_search_execute_expression):
+ Perform error handling on search expression.
+ (CamelFolderSearchPrivate): Add a camelexception for error
+ returns.
+ (camel_folder_search_execute_expression): Setup exception pointer.
+ (search_match_all): Quit on error.
+
* providers/imap/camel-imap-summary.c (message_info_load): Removed
some debug 'warnings', as they should now be displayed at the
toplevel loader, and just made the code match similar code
@@ -18,6 +28,8 @@
* camel-filter-driver.c (close_folder): avoid /0 by updating after
we've done the sync.
(close_folders): Setup the first progress report to start it off.
+ (camel_filter_driver_filter_message): Fix a fixme, check errors in
+ e_sexp parsing, etc.
2001-01-22 Christopher James Lahey <clahey@helixcode.com>
diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c
index 69229321fe..a39186cd85 100644
--- a/camel/camel-filter-driver.c
+++ b/camel/camel-filter-driver.c
@@ -761,13 +761,18 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
if (camel_filter_search_match(p->message, p->info, source_url, node->match, p->ex)) {
filtered = TRUE;
camel_filter_driver_log (driver, FILTER_LOG_START, node->name);
-#ifndef NO_WARNINGS
-#warning "Must check expression parsed and executed properly?"
-#endif
+
/* perform necessary filtering actions */
e_sexp_input_text (p->eval, node->action, strlen (node->action));
- e_sexp_parse (p->eval);
+ if (e_sexp_parse (p->eval) == -1) {
+ camel_exception_setv(ex, 1, _("Error parsing filter: %s: %s"), e_sexp_error(p->eval), node->action);
+ goto error;
+ }
r = e_sexp_eval (p->eval);
+ if (r == NULL) {
+ camel_exception_setv(ex, 1, _("Error executing filter: %s: %s"), e_sexp_error(p->eval), node->action);
+ goto error;
+ }
e_sexp_result_free (r);
if (p->terminated)
break;
@@ -786,10 +791,11 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Copy to default folder");
camel_folder_append_message (p->defaultfolder, p->message, p->info, p->ex);
}
+
+error:
+ if (filtered)
+ camel_filter_driver_log (driver, FILTER_LOG_END, NULL);
if (freeinfo)
camel_message_info_free (info);
-
- if (filtered)
- camel_filter_driver_log (driver, FILTER_LOG_END, NULL);
}
diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c
index 5663bf622f..c8c5290d37 100644
--- a/camel/camel-filter-search.c
+++ b/camel/camel-filter-search.c
@@ -615,16 +615,29 @@ gboolean camel_filter_search_match(CamelMimeMessage *message, CamelMessageInfo *
}
e_sexp_input_text (sexp, expression, strlen (expression));
- e_sexp_parse (sexp);
+ if (e_sexp_parse (sexp) == -1) {
+ if (!camel_exception_is_set(ex))
+ camel_exception_setv(ex, 1, _("Error executing filter search: %s: %s"), e_sexp_error(sexp), expression);
+ goto error;
+ }
result = e_sexp_eval (sexp);
-
+ if (result == NULL) {
+ if (!camel_exception_is_set(ex))
+ camel_exception_setv(ex, 1, _("Error executing filter search: %s: %s"), e_sexp_error(sexp), expression);
+ goto error;
+ }
+
if (result->type == ESEXP_RES_BOOL)
retval = result->value.bool;
else
retval = FALSE;
- e_sexp_unref(sexp);
e_sexp_result_free (result);
+ e_sexp_unref(sexp);
return retval;
+
+error:
+ e_sexp_unref(sexp);
+ return FALSE;
}
diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c
index c1023b5f41..45409de3c9 100644
--- a/camel/camel-folder-search.c
+++ b/camel/camel-folder-search.c
@@ -47,6 +47,7 @@
struct _CamelFolderSearchPrivate {
GHashTable *mempool_hash;
+ CamelException *ex;
};
#define _PRIVATE(o) (((CamelFolderSearch *)(o))->priv)
@@ -304,21 +305,34 @@ GPtrArray *
camel_folder_search_execute_expression(CamelFolderSearch *search, const char *expr, CamelException *ex)
{
ESExpResult *r;
- GPtrArray *matches = g_ptr_array_new ();
+ GPtrArray *matches;
int i;
GHashTable *results;
EMemPool *pool;
struct _CamelFolderSearchPrivate *p = _PRIVATE(search);
+ p->ex = ex;
+
/* only re-parse if the search has changed */
if (search->last_search == NULL
|| strcmp(search->last_search, expr)) {
e_sexp_input_text(search->sexp, expr, strlen(expr));
- e_sexp_parse(search->sexp);
+ if (e_sexp_parse(search->sexp) == -1) {
+ camel_exception_setv(ex, 1, _("Cannot parse search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+ return NULL;
+ }
+
g_free(search->last_search);
search->last_search = g_strdup(expr);
}
r = e_sexp_eval(search->sexp);
+ if (r == NULL) {
+ if (!camel_exception_is_set(ex))
+ camel_exception_setv(ex, 1, _("Error executing search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+ return NULL;
+ }
+
+ matches = g_ptr_array_new();
/* now create a folder summary to return?? */
if (r
@@ -459,6 +473,7 @@ search_match_all(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFold
g_ptr_array_add(r->value.ptrarray, (char *)camel_message_info_uid(search->current));
} else {
g_warning("invalid syntax, matches require a single bool result");
+ e_sexp_fatal_error(f, _("(match-all) requires a single bool result"));
}
e_sexp_result_free(r1);
} else {
@@ -472,6 +487,7 @@ search_match_all(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFold
if (search->summary == NULL) {
/* TODO: make it work - e.g. use the folder and so forth for a slower search */
g_warning("No summary supplied, match-all doesn't work with no summary");
+ g_assert(0);
return r;
}
@@ -485,6 +501,7 @@ search_match_all(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFold
g_ptr_array_add(r->value.ptrarray, (char *)camel_message_info_uid(search->current));
} else {
g_warning("invalid syntax, matches require a single bool result");
+ e_sexp_fatal_error(f, _("(match-all) requires a single bool result"));
}
e_sexp_result_free(r1);
} else {