offlineimap icon indicating copy to clipboard operation
offlineimap copied to clipboard

percent (%) sign in configuration raises exception

Open danmilon opened this issue 12 years ago • 5 comments

An exception is raised when the configuration contains the "%" sign in values (e.g. password). Do you know any workaround for this, or a way to fix it?

ERROR: Exceptions occurred during the run!
ERROR: While attempting to sync account '[email protected]'
  '%' must be followed by '%' or '(', found: '%!f'

Traceback:
  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 241, in syncrunner
    self.__sync()
  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 303, in __sync
    remoterepos.getfolders()
  File "/usr/lib/python2.7/site-packages/offlineimap/repository/IMAP.py", line 322, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File "/usr/lib/python2.7/site-packages/offlineimap/imapserver.py", line 418, in acquireconnection
    self.__authn_helper(imapobj)
  File "/usr/lib/python2.7/site-packages/offlineimap/imapserver.py", line 327, in __authn_helper
    if func(imapobj):
  File "/usr/lib/python2.7/site-packages/offlineimap/imapserver.py", line 253, in __authn_plain
    imapobj.authenticate('PLAIN', self.__plainhandler)
  File "/usr/lib/python2.7/site-packages/offlineimap/imaplib2.py", line 648, in authenticate
    typ, dat = self._simple_command('AUTHENTICATE', mechanism.upper())
  File "/usr/lib/python2.7/site-packages/offlineimap/imaplib2.py", line 1615, in _simple_command
    return self._command_complete(self._command(name, *args), kw)
  File "/usr/lib/python2.7/site-packages/offlineimap/imaplib2.py", line 1354, in _command
    literal = literator(data, rqb)
  File "/usr/lib/python2.7/site-packages/offlineimap/imaplib2.py", line 2163, in process
    ret = self.mech(self.decode(data))
  File "/usr/lib/python2.7/site-packages/offlineimap/imapserver.py", line 162, in __plainhandler
    passwd = self.__getpassword()
  File "/usr/lib/python2.7/site-packages/offlineimap/imapserver.py", line 111, in __getpassword
    self.password = self.repos.getpassword() or \
  File "/usr/lib/python2.7/site-packages/offlineimap/repository/IMAP.py", line 269, in getpassword
    password = self.getconf('remotepass', None)
  File "/usr/lib/python2.7/site-packages/offlineimap/CustomConfig.py", line 134, in getconf
    self.getconfig().get)
  File "/usr/lib/python2.7/site-packages/offlineimap/CustomConfig.py", line 127, in _confighelper_runner
    return defaultfunc(*(lst + list(args)))
  File "/usr/lib/python2.7/site-packages/offlineimap/CustomConfig.py", line 30, in getdefault
    return self.get(*(section, option) + args, **kwargs)
  File "/usr/lib/python2.7/ConfigParser.py", line 623, in get
    return self._interpolate(section, option, value, d)
  File "/usr/lib/python2.7/ConfigParser.py", line 691, in _interpolate
    self._interpolate_some(option, L, rawval, section, vars, 1)
  File "/usr/lib/python2.7/ConfigParser.py", line 732, in _interpolate_some
    "'%%' must be followed by '%%' or '(', found: %r" % (rest,))

danmilon avatar Sep 20 '14 11:09 danmilon

You can use %% to encode the percentage sign. It is IMHO documented in the stock configbfile

Sent from mobile phone. Please excuse brevity

spaetz avatar Sep 22 '14 15:09 spaetz

You're right. Sorry bout that!

danmilon avatar Sep 22 '14 15:09 danmilon

It is, but maybe a better error message would be useful? For example a second line saying If you want literal % in your config file, replace it with %% would directly tell the solution. It is not very easy to find this information if you don't know where to look.

m4ci3k2 avatar Jun 23 '17 18:06 m4ci3k2

Added to the FAQ.

nicolas33 avatar Jun 23 '17 21:06 nicolas33

If the config parser would catch exception ConfigParser.InterpolationError Base class for exceptions raised when problems occur performing string interpolation. then it could print the user-friendly advice how to fix the config file entry by adding %, and even print which line is the offending line. https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap/mbnames.py#L176

chris001 avatar Jun 24 '17 13:06 chris001