karastojko/mailio

send imap quoted string

yjm6560 opened this issue ยท 9 comments

hi.
i had searched imap c++ library, and this library is very helpful.
but i found a point which could be improved.

imap quoted string in LOGIN command

string can be quoted string like following pictures in rfc3501 grammar.
image
image

And userid and password containing " or \ In LOGIN command must be quoted string not plain string.
if not, imap server can't parse the imap request.
To be more specific, if password contains imap reserved character like (, ), {, }, imap server can't distinguish whether it is imap reserved character or part of password string.
and if password contains space, server would be confused.
So it will be safer to make userid and password into imap quoted string.

the way to convert plain string to imap quoted string is simple.
Just put \ in front of quoted-special characters(" and \ ), and cover it with dquote(").
e.g.

// AS-IS : imap server can't parse it
1 LOGIN userid" passwd\
// TO-BE
1 LOGIN "userid\"" "passwd\\"

Please feel free to tell me if I made a mistake.
thank you.

i will post other points which can be improved in a few days, if you don't mind..

Thank you for the valuable suggestions. Let me play a little bit with the code, and I will apply the changes.

Also, I think it would be good to consider using imap quoted string in the imap commands which uses the mailbox name.
same problem can be occurred in mailbox name.

Login now uses the quoted string on login. I will check the same for the mailbox name.

Quoted string for the folder names are also added. Tested with various commands like creating and renaming a folder, looks fine.

Seems that Zoho is not happy with a folder which contains the double quote in the name, but that's not part of this bug.

67e077e commit seems that you removed DQUOTE surrounding folder name.
i thought same way with c524e5f should be applied to folder name.

did you test folder name like test("aaa"), test)], test"aaa??
it is good to create those folders in Web and test mailio::imap::select.
i haven't tested after 67e077e commit but i think it may not work well..

I think you are right, the last change was not good, I'll have to do it in a better way.

Let's see if this time is better.

Let's see if this time is better.

it seems to work well!
there would be no work with imap quoted string if #136 is done!

There may be people who converts id,passwd and folder name to imap quoted string themselves. Therefore, it would be good to write it down in the release note that they don't have to do it themselves.