offlineimap icon indicating copy to clipboard operation
offlineimap copied to clipboard

handle enabling/disabling utf8foldernames nicely

Open nicolas33 opened this issue 8 years ago • 12 comments

The idea is to detect if each foldername is UTF-7 or UTF-8. I didn't check if direct comparison of the UTF-7 and UTF-8 names is fine. If not, encoding the "supposed UTF-8" string to UTF-7. This detection strategy is fine as long as double encoding to UTF-7 is noop.

UTF-7 to UTF-8 handling (utf8foldernames enabled)

If the "supposed UTF-8" and UTF-7 names differ, check if the UTF-7 naming is on disk and run the actions. It should be OK to assume the UTF-8 name is not on disk when the UTF-7 name is found.

UTF-8 to UTF-7 handling (utf8foldernames disabled)

When utf8foldernames is disabled, check if the UTF-7 foldername is found on disk. If so, run the actions. It should be OK to assume the UTF-7 name is not on disk when the UTF-8 name is found.

Actions

To support enabling/disabling utf8foldernames nicely would require:

  • renaming the cache files
  • renaming the maildir folders
  • updating the FMD5

nicolas33 avatar Oct 08 '17 15:10 nicolas33

@uliska Here's a mention in case you find this interesting. ,-)

nicolas33 avatar Oct 08 '17 15:10 nicolas33

You mean with the option enabled offlineIMAP should do The Right Thing (TM) regardless of whether the IMAP server uses UTF-7 or whether the user has already saved UTF-7 folders in earlier synchronization?

uliska avatar Oct 08 '17 19:10 uliska

It would be brilliant to rename on-the-fly, all with UTF-8 in order to increase readability. No more strange illegible symbols/numerical codes in filenames and foldernames.

chris001 avatar Oct 08 '17 21:10 chris001

You mean with the option enabled offlineIMAP should do The Right Thing (TM) regardless of whether the IMAP server uses UTF-7 or whether the user has already saved UTF-7 folders in earlier synchronization?

The latter so users can enable/disable utf8foldernames. This would be great to later enable utf8foldernames by default without breaking setups of users.

Actually, I have no idea what we do if the remote provides UTF-8 strings.

nicolas33 avatar Oct 08 '17 22:10 nicolas33

@chris001 Did you try utf8foldernames in v7.1.3? I did not receive a response from you during the pre-release stage.

nicolas33 avatar Oct 08 '17 22:10 nicolas33

@nicolas33 Sorry, I was preoccupied with setting up some external email accounts for the purposes of making an automated testing configuration with Travis-CI here on github!

chris001 avatar Oct 09 '17 01:10 chris001

Additional suggestion, while we're at it: The option should also be settable in the "general" section, with the possibility to override it on account level.

uliska avatar Oct 10 '17 15:10 uliska

Well, we use to rely on the config parser for this. This is called interpolation.

nicolas33 avatar Oct 10 '17 16:10 nicolas33

No, I'm not talking about interpolation. What I mean is that in general people will want to use utf8foldernames always or never. I.e. I would think of it more like a program than an account option. So I would suggest to make it possible to specify it in the `[general]' section (and alternatively as a command line switch) with the possibility of overriding it for individual accounts if that should be necessary in special cases.

uliska avatar Oct 14 '17 07:10 uliska

Ok. I'm fine with this. [deleted]

nicolas33 avatar Oct 14 '17 09:10 nicolas33

I haven't fully internalized yet how the config parser does its job, but I'd say the following should be done:

Currently the value for utf8foldernames is retrieved with a default of no, so if it is not specified in an account this account one will have no. What I suggest is that if an option is found in the [general] section the default value will be changed to whatever is given.

That way the first choice is an option given on account level, if that's not present the one specified in general (or passed as a command line option) is taken, and if that's not present either the hard-coded default of no will be used. Which will hopefully be replaced with yes at some later point.

uliska avatar Oct 14 '17 15:10 uliska

A few new things about this topic:

  1. Handling the moves to both UTF7 and UTF8 is not easy. We could only support the move to UTF8 and not allow going back to UTF7.

  2. Having fine grained tuning up to the account level might be a bit tricky to handle in the code.

So, we might rather like to only support moving to UTF8 without going back. In this case, we could introduce a new policy: create a new config file, metadatadir and maildirs while avoiding re-downloads and update everything is needed (md5, etc). Something like --convert-to-utf8 could help to keep the code as simple as possible. This way, the code about this UTF conversion might be moved out from the syncing logic.

nicolas33 avatar Mar 03 '19 10:03 nicolas33