aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-10-30 05:27:25 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-10-30 05:27:25 +0800
commit75cd5e1f3d3e898cceda5e8fb84ca8140843258d (patch)
tree5291d326fd073c047129b570c7bcd73cf716a8fc
parent0906e75d56cc2127e57009f97a6e84e65f40ae51 (diff)
downloadgsoc2013-evolution-75cd5e1f3d3e898cceda5e8fb84ca8140843258d.tar.gz
gsoc2013-evolution-75cd5e1f3d3e898cceda5e8fb84ca8140843258d.tar.zst
gsoc2013-evolution-75cd5e1f3d3e898cceda5e8fb84ca8140843258d.zip
Silently drop match strings that contain invalid utf-8... not a good thing
2001-10-29 Jon Trowbridge <trow@ximian.com> * gal/e-text/e-completion-match.c (e_completion_match_set_text): Silently drop match strings that contain invalid utf-8... not a good thing to do, but better than any of the currently available alternatives. svn path=/trunk/; revision=14364
-rw-r--r--widgets/text/e-completion-match.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/widgets/text/e-completion-match.c b/widgets/text/e-completion-match.c
index a5b26e0857..e61362a561 100644
--- a/widgets/text/e-completion-match.c
+++ b/widgets/text/e-completion-match.c
@@ -82,43 +82,42 @@ e_completion_match_set_text (ECompletionMatch *match,
const gchar *match_text,
const gchar *menu_text)
{
- gchar *to_be_freed_match_text;
- gchar *to_be_freed_menu_text;
-
g_return_if_fail (match != NULL);
- to_be_freed_match_text = match->match_text;
- to_be_freed_menu_text = match->menu_text;
+ /* We silently drop any entries w/ invalid utf8.
+ This is not optimal behavior. */
- if (match_text == NULL) {
- match_text = "Unknown_Match";
- } else if (! g_utf8_validate (match_text, -1, NULL)) {
- match_text = "Invalid_UTF8";
+ if (match_text && ! g_utf8_validate (match_text, -1, NULL)) {
+ match_text = NULL;
}
- if (menu_text == NULL) {
- menu_text = match_text;
- } else if (! g_utf8_validate (menu_text, -1, NULL)) {
- menu_text = "Invalid_UTF8";
+ if (menu_text && ! g_utf8_validate (menu_text, -1, NULL)) {
+ menu_text = NULL;
}
+ if (match->match_text && match->match_text != match_text) {
+ g_free (match->match_text);
+ }
match->match_text = g_strdup (match_text);
- match->menu_text = g_strdup (menu_text);
- g_free (to_be_freed_match_text);
- g_free (to_be_freed_menu_text);
+ if (match->menu_text && match->menu_text != menu_text) {
+ g_free (match->menu_text);
+ }
+ match->menu_text = g_strdup (menu_text);
}
const gchar *
e_completion_match_get_match_text (ECompletionMatch *match)
{
- return match ? match->match_text : "NULL_Match";
+ g_return_val_if_fail (match != NULL, NULL);
+ return match->match_text;
}
const gchar *
e_completion_match_get_menu_text (ECompletionMatch *match)
{
- return match ? match->menu_text : "NULL_Match";
+ g_return_val_if_fail (match != NULL, NULL);
+ return match->menu_text;
}
gint