Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mailbox parser error #171

Open
tiehexue opened this issue May 27, 2024 · 4 comments
Open

mailbox parser error #171

tiehexue opened this issue May 27, 2024 · 4 comments

Comments

@tiehexue
Copy link

I am trying to build a client app based on himalaya(https://github.com/soywod/himalaya), which used imap-proto 0.16.3. It crashes when parsing a mailbox with quotes, e.g. ((“name_in_base64”extraname(extrahost)”” nil “wangyuan” “host.com”)). Any advices how to fix

@tiehexue
Copy link
Author

thunderbird, apple mail, just works fine with such mailbox.

@djc
Copy link
Owner

djc commented May 27, 2024

https://www.rfc-editor.org/rfc/rfc3501#section-9:

address         = "(" addr-name SP addr-adl SP addr-mailbox SP
                  addr-host ")"
addr-name       = nstring
                    ; If non-NIL, holds phrase from [[RFC-2822](https://www.rfc-editor.org/rfc/rfc2822)]
                    ; mailbox after removing [[RFC-2822](https://www.rfc-editor.org/rfc/rfc2822)] quoting
literal         = "{" number "}" CRLF *CHAR8
                    ; Number represents the number of CHAR8s
nstring         = string / nil
quoted          = DQUOTE *QUOTED-CHAR DQUOTE
QUOTED-CHAR     = <any TEXT-CHAR except quoted-specials> /
                  "\" quoted-specials
quoted-specials = DQUOTE / "\"
string          = quoted / literal

As such, per the spec you should be escaping your quotes.

@tiehexue
Copy link
Author

tiehexue commented May 31, 2024 via email

@djc
Copy link
Owner

djc commented May 31, 2024

Extra quotes should be added through somehow in a long email thread across different mail clients and servers. I am not able to eliminate that before I saw it. Should I escape it before send to this library? 汪院

I'm open to reviewing a PR that makes the parser more robust on this front, but whether I'll want to merge it depends on the complexity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants