[firstboot] Fix username guessing with unicode chars (#677904)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 modules/create_user.py |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/modules/create_user.py b/modules/create_user.py
index d162fad..7628364 100644
--- a/modules/create_user.py
+++ b/modules/create_user.py
@@ -22,6 +22,7 @@ import libuser
 import os, string, sys, time
 import os.path
 import pwd
+import unicodedata
 
 from firstboot.config import *
 from firstboot.constants import *
@@ -413,10 +414,16 @@ class moduleClass(Module):
         try:
             user = name.split()[0]
         except IndexError:
-            user = ""
-        else:
-            user = user.encode("ascii", "ascii_transliterate")
+            user = u""
+
+        # convert to ascii (try to replace characters)
+        try:
+            nfkd = unicodedata.normalize("NFKD", user)
+            user = u"".join([c for c in nfkd if not unicodedata.combining(c)])
+            user = user.encode("ascii", "ignore")
             user = user.lower()
+        except:
+            user = ""
 
         self.usernameEntry.handler_block_by_func(self.usernameEntry_changed)
         self.usernameEntry.set_text(user)
-- 
1.7.3.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux