karastojko/mailio

parsing imap quoted string

yjm6560 opened this issue · 2 comments

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).

Work in progress.

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.