After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 699940 - Prevent whitespace-only account names
Prevent whitespace-only account names
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: User Accounts
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: Ondrej Holy
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-05-08 16:42 UTC by Chris Cummins
Modified: 2013-05-17 14:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[1/2] Dissallow whitespace-only names (1.28 KB, patch)
2013-05-08 16:45 UTC, Chris Cummins
needs-work Details | Review
[2/2] Validate real name on change (1.16 KB, patch)
2013-05-08 16:47 UTC, Chris Cummins
committed Details | Review
Screenshot showing whitespace-only account names (45.66 KB, image/png)
2013-05-09 16:06 UTC, Chris Cummins
  Details
v2: Dissallow whitespace-only names (1.40 KB, patch)
2013-05-15 12:58 UTC, Chris Cummins
needs-work Details | Review
v3: Dissallow whitespace-only names (1.87 KB, patch)
2013-05-15 15:53 UTC, Chris Cummins
needs-work Details | Review
v3: Dissallow whitespace-only names (1.86 KB, patch)
2013-05-16 10:07 UTC, Chris Cummins
committed Details | Review

Description Chris Cummins 2013-05-08 16:42:02 UTC
These changes prevent users from creating an account with an "invisible" real name consisting solely of whitespace characters (spaces and tabs). Empty account names can cause confusion on the login screen, where only the user icon shows.
Comment 1 Chris Cummins 2013-05-08 16:45:49 UTC
Created attachment 243603 [details] [review]
[1/2] Dissallow whitespace-only names

This ensures that names do not consist solely of whitespace characters when they are validated. An whitespace-only name is classed as invalid.
Comment 2 Chris Cummins 2013-05-08 16:47:07 UTC
Created attachment 243604 [details] [review]
[2/2] Validate real name on change

This prevents users from setting an invalid real name for an account by editing the name widget on the user panel. This applies the same validation as is done during account creation by the add account dialog.
Comment 3 Chris Cummins 2013-05-09 16:06:42 UTC
Created attachment 243718 [details]
Screenshot showing whitespace-only account names

In this screenshot of the accounts settings window, users `example[123]' each have unique though indistinguishable account names consisting of varying numbers of space characters. Since the login screen only shows the real name and not the system usernames, it is not possible to tell these users apart.
Comment 4 Bastien Nocera 2013-05-13 15:32:44 UTC
Review of attachment 243603 [details] [review]:

::: panels/user-accounts/um-utils.c
@@ +477,3 @@
+        /* Name cannot consist solely of whitespace */
+        for (c = name; *c; c++) {
+                if (c != ' ' && c != '\t') {

That's not a good enough test, IMO. It only checks for space and tabs, and doesn't block other UTF-8 "space" symbols.

I'd use g_unichar_isspace() and co. to check it instead.
Comment 5 Bastien Nocera 2013-05-13 15:33:46 UTC
Review of attachment 243604 [details] [review]:

That looks correct.
Comment 6 Chris Cummins 2013-05-15 12:58:16 UTC
Created attachment 244313 [details] [review]
v2: Dissallow whitespace-only names

You're right, thanks. I wasn't aware of the g_unichar_* family. Attached is a more robust version.
Comment 7 Bastien Nocera 2013-05-15 13:04:03 UTC
Review of attachment 244313 [details] [review]:

::: panels/user-accounts/um-utils.c
@@ +476,3 @@
 
+        /* Name cannot consist solely of whitespace */
+        for (c = name; *c; c++) {

Right. You also need to use g_utf8_ functions to iterate over the characters, otherwise this will break with 2-byte and bigger characters.

for (c =name; *c ; g_utf8_next_char(c))
Comment 8 Chris Cummins 2013-05-15 15:53:50 UTC
Created attachment 244335 [details] [review]
v3: Dissallow whitespace-only names

Thanks for your patience. Getting there!
Comment 9 Bastien Nocera 2013-05-16 08:26:57 UTC
Review of attachment 244335 [details] [review]:

::: panels/user-accounts/um-utils.c
@@ +481,1 @@
+                unichar = g_utf8_get_char_validated (&name[i], -1);

I doubt it compiles. Where's "i" defined?
Comment 10 Chris Cummins 2013-05-16 10:07:47 UTC
Created attachment 244385 [details] [review]
v3: Dissallow whitespace-only names

Oops, git blooper. Submitted the wrong patch, here's the tested version.
Comment 11 Bastien Nocera 2013-05-17 14:34:52 UTC
Pushed, thanks for the patches!