emersion / go-imap

📥 An IMAP library for clients and servers
MIT License
2.07k stars 293 forks source link

err : atom contains forbidden char ( #435

Closed francisLee777 closed 3 years ago

francisLee777 commented 3 years ago

when I connect to Tencent mail Server by client.DialTLS("pop.qq.com:995", nil) it return an error called atom contains forbidden char :(.

In this function, client will greet to the server by c.handleGreetAndStartReading() .

by debugging this function, I find the server successfully returns this message +OK XMail POP3 Server v1.0 Service Ready(XMail v1.0) in the response, but func (r *Reader) ReadAtom() (interface{}, error) in read.go reads the " Ready(XMail v1.0)" in the message and return an error because the content contains '(' character.

As a result, I can't connect to the Tencent mail Server successfully.

foxcpp commented 3 years ago

From RFC 3501 (IMAP4rev1):

greeting        = "*" SP (resp-cond-auth / resp-cond-bye) CRLF
resp-cond-auth  = ("OK" / "PREAUTH") SP resp-text
                    ; Authentication condition
resp-text       = ["[" resp-text-code "]" SP] text
text            = 1*TEXT-CHAR
TEXT-CHAR       = <any CHAR except CR and LF>

From RFC 5234 (ABNF):

         CHAR           =  %x01-7F
                                ; any 7-bit US-ASCII character,
                                ;  excluding NUL

FWIW Tencent Mail Server seems to be breaking RFCs by including non-ASCII characters where they are not alloweed.

francisLee777 commented 3 years ago

From RFC 3501 (IMAP4rev1):

greeting        = "*" SP (resp-cond-auth / resp-cond-bye) CRLF
resp-cond-auth  = ("OK" / "PREAUTH") SP resp-text
                    ; Authentication condition
resp-text       = ["[" resp-text-code "]" SP] text
text            = 1*TEXT-CHAR
TEXT-CHAR       = <any CHAR except CR and LF>

From RFC 5234 (ABNF):

         CHAR           =  %x01-7F
                                ; any 7-bit US-ASCII character,
                                ;  excluding NUL

FWIW Tencent Mail Server seems to be breaking RFCs by including non-ASCII characters where they are not alloweed.

Yes I know,but this is not the reason that the library throws error. The '(' character which the greeting text contains leads to this error, but '(' is US-ASCII %x28, that is a correct character. Thanks for your reply 😀.

Lark20210719-234349

foxcpp commented 3 years ago

Oh, I am blind. Right, greeting parsing should allow more than what atom would.

foxcpp commented 3 years ago

Also, it seems like you trying to connect to the POP3 server instead of IMAP4 one.

foxcpp commented 3 years ago

I verified the go-imap code and it handles non-atom characters in info correctly.

francisLee777 commented 3 years ago

so how can I parse the greeting message successfully?   thanks a lot.

------------------ 原始邮件 ------------------ 发件人: "Max @.>; 发送时间: 2021年7月20日(星期二) 凌晨1:20 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [emersion/go-imap] err : atom contains forbidden char ( (#435)

Oh, I am blind. Right, greeting parsing should allow more than what atom would.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

francisLee777 commented 3 years ago

Oh, I am blind. Right, greeting parsing should allow more than what atom would.

so how can I parse the greeting message successfully? thanks a lot.