diff options
author | Brian Cameron <brian.cameron@sun.com> | 2007-04-06 02:23:33 +0000 |
---|---|---|
committer | Brian Cameron <bcameron@src.gnome.org> | 2007-04-06 02:23:33 +0000 |
commit | 38ff806cb1e136799f7103023cad777888f07e2a (patch) | |
tree | 05a086e34db3d7a098d99d7fc68833a98ade13cb /gui | |
parent | 3b5bf602a9090f07feadb8e3a8e1934e376e1faf (diff) | |
download | gdm-38ff806cb1e136799f7103023cad777888f07e2a.tar.gz |
Usernames with non-utf8 characters were causing GDM GUI to crash when it
2007-04-06 Brian Cameron <brian.cameron@sun.com>
* gui/gdmcommon.[ch], gui/gdmlogin.c,
gui/greeter/greeter_item_ulist.c: Usernames with non-utf8
characters were causing GDM GUI to crash when it tried to
display in the face browser. This patch fixes so non-utf8
characters display as '?'. Fixes bug #426647. Patch by
Ray Strode <rstrode@redhat.com>.
svn path=/trunk/; revision=4769
Diffstat (limited to 'gui')
-rw-r--r-- | gui/gdmcommon.c | 23 | ||||
-rw-r--r-- | gui/gdmcommon.h | 1 | ||||
-rw-r--r-- | gui/gdmlogin.c | 4 | ||||
-rw-r--r-- | gui/greeter/greeter_item_ulist.c | 4 |
4 files changed, 28 insertions, 4 deletions
diff --git a/gui/gdmcommon.c b/gui/gdmcommon.c index eb478b50..dfea2d1e 100644 --- a/gui/gdmcommon.c +++ b/gui/gdmcommon.c @@ -387,6 +387,29 @@ gdm_common_get_face (const char *filename, } gchar * +gdm_common_text_to_escaped_utf8 (const char *text) +{ + gchar *utf8_string, *escaped_string, *p; + const gchar *q; + + utf8_string = g_strdup (text); + p = utf8_string; + while ((*p != '\0') && + !g_utf8_validate (p, -1, &q)) { + p = (gchar *) q; + p = '?'; + p++; + } + + g_assert (g_utf8_validate (utf8_string, -1, NULL)); + + escaped_string = g_markup_escape_text (utf8_string, -1); + g_free (utf8_string); + + return escaped_string; +} + +gchar * gdm_common_get_config_file (void) { gchar *result; diff --git a/gui/gdmcommon.h b/gui/gdmcommon.h index f6481e0d..f8331f89 100644 --- a/gui/gdmcommon.h +++ b/gui/gdmcommon.h @@ -59,6 +59,7 @@ GdkPixbuf *gdm_common_get_face (const char *filename, guint max_width, guint max_height); +gchar* gdm_common_text_to_escaped_utf8 (const char *text); gchar* gdm_common_get_config_file (void); gchar* gdm_common_get_custom_config_file (void); gboolean gdm_common_select_time_format (void); diff --git a/gui/gdmlogin.c b/gui/gdmlogin.c index 9e6a2a85..8dbb1704 100644 --- a/gui/gdmlogin.c +++ b/gui/gdmlogin.c @@ -1803,8 +1803,8 @@ gdm_login_browser_populate (void) char *label; char *login, *gecos; - login = g_markup_escape_text (usr->login, -1); - gecos = g_markup_escape_text (usr->gecos, -1); + login = gdm_common_text_to_escaped_utf8 (usr->login); + gecos = gdm_common_text_to_escaped_utf8 (usr->gecos); label = g_strdup_printf ("<b>%s</b>\n%s", login, diff --git a/gui/greeter/greeter_item_ulist.c b/gui/greeter/greeter_item_ulist.c index f35693f5..20cad3e4 100644 --- a/gui/greeter/greeter_item_ulist.c +++ b/gui/greeter/greeter_item_ulist.c @@ -200,9 +200,9 @@ greeter_populate_user_list (GtkTreeModel *tm) gboolean active; if (usr->gecos && strcmp (usr->gecos, "") != 0) { - name = g_markup_escape_text (usr->gecos, -1); + name = gdm_common_text_to_escaped_utf8 (usr->gecos); } else { - name = g_markup_escape_text (usr->login, -1); + name = gdm_common_text_to_escaped_utf8 (usr->login); } if (g_hash_table_lookup (displays_hash, usr->login)) |