From 574642a0e773cf2782c9689ded033bd5c0cf2a34 Mon Sep 17 00:00:00 2001 From: tom Date: Mon, 24 Nov 2014 11:35:29 +0100 Subject: [PATCH] fix utf-8 account names --- yubicoauthenticator/ui_addaccount.py | 4 ++-- yubicoauthenticator/ui_main.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/yubicoauthenticator/ui_addaccount.py b/yubicoauthenticator/ui_addaccount.py index 79d40b94..f2dcfbbd 100644 --- a/yubicoauthenticator/ui_addaccount.py +++ b/yubicoauthenticator/ui_addaccount.py @@ -81,7 +81,7 @@ class Ui_AddAccount(QtGui.QDialog): self.label_3.setText("Secret Key") #set place holder text - self.lineEdit.setPlaceholderText("tom@example.com") + self.lineEdit.setPlaceholderText("johndoe@example.com") self.lineEdit_2.setPlaceholderText("thei ncre dibl ehul kisi nmod hex!") # set modal option self.setModal(True) @@ -91,7 +91,7 @@ class Ui_AddAccount(QtGui.QDialog): def verify(self): #set the data and quit # WARNING THE lineEdit.text() RETURNS A UNICODE - self.new_account['ACCOUNT_NAME'] = self.lineEdit.text().encode('utf-8') + self.new_account['ACCOUNT_NAME'] = self.lineEdit.text().encode('utf-8').strip() #remove whitespace self.new_account['SECRET_KEY'] = self.lineEdit_2.text().replace(" ", "") diff --git a/yubicoauthenticator/ui_main.py b/yubicoauthenticator/ui_main.py index cc1e73e3..08966040 100644 --- a/yubicoauthenticator/ui_main.py +++ b/yubicoauthenticator/ui_main.py @@ -268,11 +268,11 @@ class Ui_Dialog(object): for credential in cred_list: if credential.algorithm == 'totp': - self.leftList.addItem(str(credential.name)) + self.leftList.addItem(str(credential.name).decode('utf-8').strip()) self.rightList.addItem(str(credential.code)) else: - self.leftList.addItem(str(credential.name)) + self.leftList.addItem(str(credential.name).decode('utf-8').strip()) self.rightList.addItem('HOTP') #identify the row and set the tooltip @@ -299,6 +299,7 @@ class Ui_Dialog(object): #strip off white spaces new_account['ACCOUNT_NAME'].replace(" ", "") new_account['SECRET_KEY'].replace(" ", "") + #new_account['ACCOUNT_NAME'] = str(new_account['ACCOUNT_NAME']).encode("utf-8").strip() #run the PUT command yc.execute_command("put", new_account) self.refresh()