fix: configparser does not know about python types like u""

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/347
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2016-07-13 01:11:08 +02:00
parent 7b425d4c87
commit 1a96d588d5
2 changed files with 20 additions and 17 deletions

View File

@ -765,9 +765,9 @@ remotehost = examplehost
# This option stands in the [Repository RemoteExample] section.
#
# Specify the remote user name. Must be unicode.
# Specify the remote user name.
#
remoteuser = u"username"
remoteuser = username
# This option stands in the [Repository RemoteExample] section.
@ -783,9 +783,7 @@ remoteuser = u"username"
# mechanism, so consider using auth_mechanisms to prioritize PLAIN
# or even make it the only mechanism to be tried.
#
# Must be unicode type.
#
#remote_identity = u"authzuser"
#remote_identity = authzuser
# This option stands in the [Repository RemoteExample] section.
@ -866,11 +864,14 @@ remoteuser = u"username"
# OfflineIMAP starts when using a UI that supports this.
#
# 2. The remote password stored in this file with the remotepass
# option. Any '%' needs to be encoded as '%%'. Example:
#remotepass = u"myp%%ssword" # Password is: myp%ssword
# option. Save this file with the UTF-8 encoding if your server expect UTF-8
# encoded password.
#
# 3. The remote password stored as a single line in an external
# file, which is referenced by the remotefile option. Example:
# Any '%' needs to be encoded as '%%'. Example:
#remotepass = myp%%ssword # Real password is myp%ssword
#
# 3. The remote password stored as a single line in an external file, which is
# referenced by the remotefile option. Must be UTF-8 encoded. Example:
#remotepassfile = ~/Password.IMAP.Account1
#
# 4. With a preauth tunnel. With this method, you invoke an external
@ -1222,9 +1223,7 @@ type = Gmail
#
# Specify the Gmail user name. This is the only mandatory parameter.
#
# Must be unicode type.
#
remoteuser = u"username@gmail.com"
remoteuser = username@gmail.com
# This option stands in the [Repository GmailExample] section.

View File

@ -184,9 +184,11 @@ class IMAPRepository(BaseRepository):
return localeval.eval(user).encode('UTF-8')
if self.config.has_option(self.getsection(), 'remoteuser'):
# Assume the configuration file to be UTF-8 encoded so we must not
# encode this string again.
user = self.getconf('remoteuser')
if user != None:
return user.encode('UTF-8')
return user
try:
netrcentry = netrc.netrc().authenticators(self.gethost())
@ -355,7 +357,9 @@ class IMAPRepository(BaseRepository):
# 2. read password from Repository 'remotepass'
password = self.getconf('remotepass', None)
if password != None:
return password.encode('UTF-8')
# Assume the configuration file to be UTF-8 encoded so we must not
# encode this string again.
return password
# 3. read password from file specified in Repository 'remotepassfile'
passfile = self.getconf('remotepassfile', None)
if passfile != None: