From 54054c1c9fde8bd14f80dc2cd564bbc258a85341 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 19 Jul 2013 09:07:04 +0530 Subject: [PATCH] Allow using non-ascii chars in email passwords Fixes #1202825 [SMTP password with special characters not stored correctly](https://bugs.launchpad.net/calibre/+bug/1202825) --- src/calibre/gui2/email.py | 2 +- src/calibre/gui2/wizard/send_email.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/email.py b/src/calibre/gui2/email.py index 665b19cc5a..6645441158 100644 --- a/src/calibre/gui2/email.py +++ b/src/calibre/gui2/email.py @@ -113,7 +113,7 @@ class Sendmail(object): verbose=1, relay=opts.relay_host, username=opts.relay_username, - password=unhexlify(opts.relay_password), port=opts.relay_port, + password=unhexlify(opts.relay_password).decode('utf-8'), port=opts.relay_port, encryption=opts.encryption, debug_output=log.debug) finally: diff --git a/src/calibre/gui2/wizard/send_email.py b/src/calibre/gui2/wizard/send_email.py index 0dc6861116..b183af1744 100644 --- a/src/calibre/gui2/wizard/send_email.py +++ b/src/calibre/gui2/wizard/send_email.py @@ -32,7 +32,7 @@ class TestEmail(QDialog, TE_Dialog): self.to.setText(pa) if opts.relay_host: self.label.setText(_('Using: %(un)s:%(pw)s@%(host)s:%(port)s and %(enc)s encryption')% - dict(un=opts.relay_username, pw=unhexlify(opts.relay_password), + dict(un=opts.relay_username, pw=unhexlify(opts.relay_password).decode('utf-8'), host=opts.relay_host, port=opts.relay_port, enc=opts.encryption)) def test(self, *args): @@ -129,7 +129,7 @@ class SendEmail(QWidget, Ui_Form): self.relay_username.setText(opts.relay_username) self.relay_username.textChanged.connect(self.changed) if opts.relay_password: - self.relay_password.setText(unhexlify(opts.relay_password)) + self.relay_password.setText(unhexlify(opts.relay_password).decode('utf-8')) self.relay_password.textChanged.connect(self.changed) getattr(self, 'relay_'+opts.encryption.lower()).setChecked(True) self.relay_tls.toggled.connect(self.changed) @@ -169,7 +169,7 @@ class SendEmail(QWidget, Ui_Form): sendmail(msg, from_=opts.from_, to=[to], verbose=3, timeout=30, relay=opts.relay_host, username=opts.relay_username, - password=unhexlify(opts.relay_password), + password=unhexlify(opts.relay_password).decode('utf-8'), encryption=opts.encryption, port=opts.relay_port) except: import traceback @@ -248,7 +248,7 @@ class SendEmail(QWidget, Ui_Form): conf.set('relay_host', host if host else None) conf.set('relay_port', self.relay_port.value()) conf.set('relay_username', username if username else None) - conf.set('relay_password', hexlify(password)) + conf.set('relay_password', hexlify(password.encode('utf-8'))) conf.set('encryption', enc_method) return True