On Thu, Apr 30, 2020 at 05:33:02PM +0200, Max Gautier wrote:
This is a WIP to add IMAP UTF-7 support. I'm not done but I'd rather
have early feedback to see if I'm going in the right direction.
What's done so far :
- adding encoding and decoding function IMAP UTF7 <-> system local
encoding. (using iconv)
i don't think you should keep re-opening the iconv_t all the time. a
file static should do.
- Add a conversion modifier to imap_vprintf to write a local encode
string as IMAP UTF7 string.
to avoid allocations and copies, pass the pre-allocated buffer to the
conversion function.
- Hook into parse_list_rsp_p2 to have box names in the local encoding
- Modify the "SELECT" command string to use the new conversion (this is
only to test that it works, I guess removing the \ modifier is not
ideal)
What remains to be done (IMO):
- Better error handling (in encoding/decoding, what to do if locale does
not support something, or vice versa ?)
i'm assuming ucs-4 is supposed to be decomposed to surrogate pairs, so
it's fully encodable as utf-7, which means that any valid unicode
character is representable.
however, there might be an error trying to decode the 8-bit locale
input. that should somehow lead to a DRV_BOX_BAD, which means that
imap_vprintf() needs to return NULL after printing an error, and
imap_exec() needs to interpret it.
failure to decode should drop a warning and skip the mailbox, like the
other early exits in parse_list_rsp_p2() do.
- Make ^ and / cooperates in imap_vprintf
depending on what you mean by "cooperate" - utf-7 covers "escaping"
quotes and backslashes, so there is no direct concern about that.
however, to keep the imap stream human-readable, ^ should automatically
fall back to \ semantics when only plain ascii is present in the string.
- Add the ^ modifiers where appropriate in imap commands strings (I
suppose that would be CREATE, some others ?
APPEND, DELETE, MOVE, COPY, LIST - basically, all matches of %\\s except
for the LOGIN.
Thanks to let me know if I'm doing it wrong or have missed something.
in the end i'll bikeshed it to shreds and rewrite at least half of it
anyway (that's what i always do), but i can't see anything fundamentally
wrong about it ... after all, you're just following my advice from
https://sourceforge.net/p/isync/bugs/47/ ...
_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel