"Invalid character in literal" for Gmail
bkaankose opened this issue · 4 comments
Describe the bug
Command gets rejected with 'invalid character in literal' message when trying to append a MimeMessage to Gmail's Draft folder.
I ran some diagnosis and found out that Epilogue property contains empty literals
Setting this property to empty string in the debugger window succeeds the command. Interesting thing is that when I run the same code with the same generated MimeMessage for iCloud servers, no exceptions. So it's something that Gmail may have updated on their end lately. I don't really remember having this issue lately, but also not sure since my code is updated regularly.
Platform (please complete the following information):
- OS: Windows
- .NET Framework: netstandard2.0
- MailKit Version: 4.7.1.1
Exception
Message: Invalid character in literal.
StackTrace:
at MailKit.Net.Imap.ImapEngine.OnImapProtocolException(ImapProtocolException ex)
at MailKit.Net.Imap.ImapEngine.<IterateAsync>d__201.MoveNext()
at MailKit.Net.Imap.ImapEngine.<RunAsync>d__203.MoveNext()
at MailKit.Net.Imap.ImapFolder.<AppendAsync>d__158.MoveNext()
at Wino.Core.Synchronizers.ImapSynchronizer.<>c__DisplayClass27_0.<<CreateDraft>b__0>d.MoveNext() in D:\GitHub\Wino-Mail\Wino.Core\Synchronizers\ImapSynchronizer.cs:line 289
at Wino.Core.Synchronizers.ImapSynchronizer.<ExecuteNativeRequestsAsync>d__36.MoveNext() in D:\GitHub\Wino-Mail\Wino.Core\Synchronizers\ImapSynchronizer.cs:line 520
at Wino.Core.Synchronizers.BaseSynchronizer`2.<SynchronizeAsync>d__20.MoveNext() in D:\GitHub\Wino-Mail\Wino.Core\Synchronizers\BaseSynchronizer.cs:line 151
Protocol Logs
Sharing as screenshot from VS Code since the log contains html body.
Can you share your code that constructs these messages?
It isn't normal for them to have those nuls in the Epilogue and that is not created by MimeKit by default afaict.
Thank you for the info.
I'll try to create a simple repo during the day.
Any updates on this? I haven't been able to figure out how you got this to happen.
Does your code load the Multipart from disk or from a database or anything? Or do you create it using new Multipart (...)
and then adding parts?
The only way I can see this happening is if you use MimeEntity.Load()
and pass it a stream that has null bytes at the end of it.
Any updates on this? I haven't been able to figure out how you got this to happen.
Does your code load the Multipart from disk or from a database or anything? Or do you create it using
new Multipart (...)
and then adding parts?The only way I can see this happening is if you use
MimeEntity.Load()
and pass it a stream that has null bytes at the end of it.
I abstracted the problematic part to a new console app and the error went away. Thing is, I base64 encode the MimeMessage in the client and decode it in the server. Transport is also done with json. I believe something goes wrong during this process. Server loads the MimeMessage with Load after all this deserialization thing.
I am closing the issue since it's not directly related to MailKit. Thanks for the MimeEntity.Load hint @jstedfast !