karastojko / mailio

mailio is a cross platform C++ library for MIME format and SMTP, POP3 and IMAP protocols. It is based on standard C++ 17 and Boost library.
Other
372 stars 98 forks source link

parsing imap quoted string #136

Closed yjm6560 closed 10 months ago

yjm6560 commented 1 year ago

Related issue

134

Suggestion

When parsing response from imap server, it should consider whether the response token is imap quoted string or not.

e.g. If I send LIST command and expected mailbox name is mailbox_"important"_, imap server would give that name as "mailbox_\"important\"_"(converted to imap quoted string).

$ openssl s_client -connect imap.gmail.com:993 -quiet -crlf
... # imap login
2 LIST "" "*" # request LIST command
# receive response
... # other mailboxes
* LIST (\HasNoChildren) "/" "mailbox_\"important\"_" # mailbox_"important"_ -> mailbox_\"important\"_
... # other mailboxes
2 OK Success # tagged response

Current mailio::imap::parse_response function may split mailbox name into mailbox_\, important\ and _ since it doesn't consider imap quoted string format. then mailio::imap::list_folder function would raise exception since token size is invalid(more than 3).

karastojko commented 10 months ago

Work in progress.

karastojko commented 10 months ago

Now it looks it's working as expected and does not break the existing functionality. I will do few more tests before merging to the main.