Merge lp:~cjwatson/ubiquity/default-username-783295 into lp:ubiquity

Proposed by Colin Watson on 2012-03-20
Status: Merged
Merged at revision: 5286
Proposed branch: lp:~cjwatson/ubiquity/default-username-783295
Merge into: lp:ubiquity
Diff against target: 52 lines (+23/-0)
3 files modified
debian/changelog (+1/-0)
tests/test_usersetup.py (+20/-0)
ubiquity/plugins/ubi-usersetup.py (+2/-0)
To merge this branch: bzr merge lp:~cjwatson/ubiquity/default-username-783295
Reviewer Review Type Date Requested Status
Evan (community) 2012-03-20 Approve on 2012-03-20
Review via email: mp+98527@code.launchpad.net

Description of the Change

Strip invalid characters from default username (LP: #783295).

To post a comment you must log in.
Evan (ev) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-03-20 19:47:50 +0000
3+++ debian/changelog 2012-03-20 22:02:20 +0000
4@@ -3,6 +3,7 @@
5 [ Colin Watson ]
6 * Fix misc.set_indicator_keymaps to handle ll_CC forms of lang, and also
7 to avoid crashing on unknown languages in general (LP: #960047).
8+ * Strip invalid characters from default username (LP: #783295).
9
10 [ Oliver Grawert ]
11 * add support for automatic-oem-config kernel commandline option to the
12
13=== modified file 'tests/test_usersetup.py'
14--- tests/test_usersetup.py 2012-03-19 21:19:23 +0000
15+++ tests/test_usersetup.py 2012-03-20 22:02:20 +0000
16@@ -114,3 +114,23 @@
17 self.gtk.login_encrypt.set_active(True)
18 self.gtk.on_authentication_toggled(self.gtk.login_encrypt)
19 self.assertTrue(self.gtk.login_pass.get_active())
20+
21+ def test_default_username(self):
22+ self.gtk.controller.get_string = mock_get_string
23+ self.gtk.set_fullname('Example Person')
24+ # Shortcut initialization
25+ self.gtk.fullname.set_name('fullname')
26+ self.gtk.username_edited = False
27+ self.gtk.info_loop(self.gtk.fullname)
28+ self.assertEqual('example', self.gtk.get_username())
29+ self.assertUsernameErrors([], self.gtk.get_username())
30+
31+ def test_default_username_strips_invalid_characters(self):
32+ self.gtk.controller.get_string = mock_get_string
33+ self.gtk.set_fullname('&Foo!$ Bar!')
34+ # Shortcut initialization
35+ self.gtk.fullname.set_name('fullname')
36+ self.gtk.username_edited = False
37+ self.gtk.info_loop(self.gtk.fullname)
38+ self.assertEqual('foo', self.gtk.get_username())
39+ self.assertUsernameErrors([], self.gtk.get_username())
40
41=== modified file 'ubiquity/plugins/ubi-usersetup.py'
42--- ubiquity/plugins/ubi-usersetup.py 2012-02-22 02:04:29 +0000
43+++ ubiquity/plugins/ubi-usersetup.py 2012-03-20 22:02:20 +0000
44@@ -319,6 +319,8 @@
45 new_username = misc.utf8(widget.get_text().split(' ')[0])
46 new_username = new_username.encode('ascii', 'ascii_transliterate')
47 new_username = new_username.lower()
48+ new_username = re.sub('^[^a-z]+', '', new_username)
49+ new_username = re.sub('[^-a-z0-9_]', '', new_username)
50 self.username.set_text(new_username)
51 self.username.handler_unblock(self.username_changed_id)
52 elif (widget is not None and widget.get_name() == 'username' and

Subscribers

People subscribed via source and target branches

to status/vote changes: