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

envelope parse Invaild symbol #669

Open
DawnSouther opened this issue Apr 21, 2023 · 0 comments
Open

envelope parse Invaild symbol #669

DawnSouther opened this issue Apr 21, 2023 · 0 comments

Comments

@DawnSouther
Copy link

Describe the bug
This is the envelope of a mail, please pay attention to the bold part

* 364 FETCH (ENVELOPE ("Wed, 6 Apr 2022 17:10:18 +0800 (CST)" "=?utf-8?B?44CQQk9TU+ebtOiBmOOAkeW0lOS9s+aXreeahOeugOWOhg==?=" (("=?utf-8?B?Qk9TU+ebtOiBmA==?=" NIL "cv" "notice.zhipin.com")) (("=?utf-8?B?Qk9TU+ebtOiBmA==?=" NIL "cv" "notice.zhipin.com")) (("=?utf-8?B?Qk9TU+ebtOiBmA==?=" NIL "cv" "notice.zhipin.com")) (("=?utf-8?B?NTcxODYzNTU5?=" NIL "571863559" "qq.com")) NIL NIL NIL "<1763943481.139839.1649236218178.JavaMail."[email protected]"@v-bosszpmail-01>") INTERNALDATE "6-Apr-2022 17:10:18 +0800" RFC822.SIZE 1103217)

"<1763943481.139839.1649236218178.JavaMail."[email protected]"@v-bosszpmail-01>" This is the part of messageId, but due to the existence of ", when com.sun.mail.iap.Response#readString() is called, it is detected and returned directly, and then com/sun/mail/imap/protocol/ENVELOPE.java:112 contains

if (!r.isNextNonSpace(')'))
     throw new ParsingException("ENVELOPE parse error");

because it cannot be detected ) Second, the parsing fails, but the email has not been parsed yet.

The reason is that ·com.sun.mail.iap.Response#parseString()· detected "termination,

	    while (index < size && (b = buffer[index]) != '"') {
		if (b == '\\') // skip escaped byte
		    index++;
		if (index != copyto) { // only copy if we need to
		    // Beware: this is a destructive copy. I'm 
		    // pretty sure this is OK, but ... ;>
		    buffer[copyto] = buffer[index];
		}

I don't know if his format violates the specification of envelop, but other libs can be parsed,So is this a bug?

Expected behavior
parse success

Screenshots
error stack

A22 OK FETCH Completed
A23 FETCH 364 (ENVELOPE INTERNALDATE RFC822.SIZE)
* 364 FETCH (ENVELOPE ("Wed, 6 Apr 2022 17:10:18 +0800 (CST)" "=?utf-8?B?44CQQk9TU+ebtOiBmOOAkeW0lOS9s+aXreeahOeugOWOhg==?=" (("=?utf-8?B?Qk9TU+ebtOiBmA==?=" NIL "cv" "notice.zhipin.com")) (("=?utf-8?B?Qk9TU+ebtOiBmA==?=" NIL "cv" "notice.zhipin.com")) (("=?utf-8?B?Qk9TU+ebtOiBmA==?=" NIL "cv" "notice.zhipin.com")) (("=?utf-8?B?NTcxODYzNTU5?=" NIL "571863559" "qq.com")) NIL NIL NIL "<1763943481.139839.1649236218178.JavaMail."[email protected]"@v-bosszpmail-01>") INTERNALDATE "6-Apr-2022 17:10:18 +0800" RFC822.SIZE 1103217)
A23 OK FETCH Completed
DEBUG IMAPS: ignoring bad response, THROW: 
com.sun.mail.iap.ParsingException: ENVELOPE parse error
	at com.sun.mail.imap.protocol.ENVELOPE.<init>(ENVELOPE.java:113)
	at com.sun.mail.imap.protocol.FetchResponse.parseItem(FetchResponse.java:220)
	at com.sun.mail.imap.protocol.FetchResponse.parse(FetchResponse.java:188)
	at com.sun.mail.imap.protocol.FetchResponse.<init>(FetchResponse.java:72)
	at com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:390)
	at com.sun.mail.iap.Protocol.command(Protocol.java:370)
	at com.sun.mail.imap.protocol.IMAPProtocol.fetch(IMAPProtocol.java:2135)
	at com.sun.mail.imap.protocol.IMAPProtocol.fetch(IMAPProtocol.java:2127)
	at com.sun.mail.imap.IMAPMessage.loadEnvelope(IMAPMessage.java:1469)
	at com.sun.mail.imap.IMAPMessage.getSentDate(IMAPMessage.java:448)

Mail server:

  • Protocol being used: imap
  • Vendor/product: tencent
  • Mail service URL: imap.qq.com

Additional context
Add any other context about the problem here.

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

1 participant