diff --git a/src/mu-cmd-server.c b/src/mu-cmd-server.c index eb31d886..b33ec58a 100644 --- a/src/mu-cmd-server.c +++ b/src/mu-cmd-server.c @@ -216,7 +216,7 @@ cmd_from_string (const char *str) static Cmd -parse_line (const gchar *line, GSList **args) +parse_line (const gchar *line, GSList **args, GError **err) { Cmd cmd; GSList *lst; @@ -226,7 +226,7 @@ parse_line (const gchar *line, GSList **args) if (!line) return CMD_IGNORE; - lst = mu_str_esc_to_list (line); + lst = mu_str_esc_to_list (line, err); if (!lst) return CMD_INVALID; @@ -1014,9 +1014,12 @@ mu_cmd_server (MuStore *store, MuConfig *opts, GError **err) GError *my_err; line = my_readline (MU_PROMPT); - cmd = parse_line (line, &args); + cmd = parse_line (line, &args, err); g_free (line); + if (cmd == CMD_INVALID) + + my_err = NULL; if (!handle_command (cmd, store, query, args, &my_err)) g_clear_error (&my_err); diff --git a/src/mu-query.cc b/src/mu-query.cc index db68de04..bac11193 100644 --- a/src/mu-query.cc +++ b/src/mu-query.cc @@ -194,7 +194,10 @@ get_query (MuQuery *mqx, const char* searchexpr, GError **err) Xapian::Query query; char *preprocessed; - preprocessed = mu_query_preprocess (searchexpr); + preprocessed = mu_query_preprocess (searchexpr, err); + if (!preprocessed) + throw std::runtime_error + ("parse error while preprocessing query"); try { query = mqx->query_parser().parse_query @@ -278,7 +281,7 @@ mu_query_destroy (MuQuery *self) /* preprocess a query to make them a bit more promiscuous */ char* -mu_query_preprocess (const char *query) +mu_query_preprocess (const char *query, GError **err) { GSList *parts, *cur; gchar *myquery; @@ -287,7 +290,9 @@ mu_query_preprocess (const char *query) /* convert the query to a list of query terms, and escape them * separately */ - parts = mu_str_esc_to_list (query); + parts = mu_str_esc_to_list (query, err); + if (!parts) + return NULL; for (cur = parts; cur; cur = g_slist_next(cur)) { /* remove accents and turn to lower-case */ diff --git a/src/mu-query.h b/src/mu-query.h index fc64b6e3..4686d6c2 100644 --- a/src/mu-query.h +++ b/src/mu-query.h @@ -113,7 +113,7 @@ char* mu_query_as_string (MuQuery *self, const char* searchexpr, GError **err) * * @return a pre-processed query, free it with g_free */ -char* mu_query_preprocess (const char *query) +char* mu_query_preprocess (const char *query, GError **err) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; G_END_DECLS