fix utf-8 account names

This commit is contained in:
tom 2014-11-24 11:35:29 +01:00
parent f39a9d65eb
commit 574642a0e7
2 changed files with 5 additions and 4 deletions

View File

@ -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(" ", "")

View File

@ -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()