Comments (13)
That is my fault. When i changed to correctly parse displaynames containing "," using the .NET framework.
The message you are downloading probably have a ";" in one of the To,From,Reply-To,Cc or Bcc fields. this is not ok by standard (so the .NET framework throws on this) however it is quite common in spam emails.
I'm working on a fix, and it will be done in the next few days. But just to be sure can you confirm if this message is spam or not, and if possible post any header line of the above containing this ";" ?
from s22.imap.
Yes this is a spam message, but it breaks the app. Appreciate the fix.
On Fri, Mar 22, 2013 at 3:45 AM, Christian Nilsson <[email protected]
wrote:
That is my fault. When i changed to correctly parse displaynames
containing "," using the .NET framework.The message you are downloading probably have a ";" in one of the
To,From,Reply-To,Cc or Bcc fields. this is not ok by standard (so the .NET
framework throws on this) however it is quite common in spam emails.I'm working on a fix, and it will be done in the next few days. But just
to be sure can you confirm if this message is spam or not, and if possible
post any header line of the above containing this ";" ?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/48#issuecomment-15288313
.
from s22.imap.
This is the address:
Fidelity Life Insurance
[email protected]<=?UTF-8?B?b3Bxa3V2QG0ubGluYWFrZW4uY29t?=@
yahoo.com>;
On Fri, Mar 22, 2013 at 3:45 AM, Christian Nilsson <[email protected]
wrote:
That is my fault. When i changed to correctly parse displaynames
containing "," using the .NET framework.The message you are downloading probably have a ";" in one of the
To,From,Reply-To,Cc or Bcc fields. this is not ok by standard (so the .NET
framework throws on this) however it is quite common in spam emails.I'm working on a fix, and it will be done in the next few days. But just
to be sure can you confirm if this message is spam or not, and if possible
post any header line of the above containing this ";" ?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/48#issuecomment-15288313
.
from s22.imap.
@rboy1 You should handle exceptions on GetMessage so the app do not break. ;)
A quick fix in this case is to change mcol.Add(list);
to mcol.Add(list.Trim(';'));
(in MessageBuilder.cs function ParseAddressList(string list) )
Unfortunately there is several variants of this that need to be handled. but hope this helps you short term.
from s22.imap.
Short term I am catching and ignoring the emails. Will wait for your fix
On Mar 22, 2013, at 12:26 PM, Christian Nilsson [email protected] wrote:
@rboy1 You should handle exceptions on GetMessage so the app do not break. ;)
A quick fix in this case is to change mcol.Add(list); to mcol.Add(list.Trim(';')); (in MessageBuilder.cs function ParseAddressList(string list) )Unfortunately there is several variants of this that need to be handled. but hope this helps you short term.
—
Reply to this email directly or view it on GitHub.
from s22.imap.
Thanks,
the call to ParseAddressList should be wrapped in a try/catch block so that no exception can bubble up to the user. Will be fixed shortly!
from s22.imap.
For now I created a fix in #49
I can not find a good solution to "catch" that the address was not parsed correctly. any Idéas?
from s22.imap.
We should just wrap the call to MailAddressCollection's Add method in try/catch. If the Add method throws an exception, it already means the address list contains illegal characters or is malformed.
try {
MailAddressCollection mcol = new MailAddressCollection();
// Use .NET internal MailAddressParser.ParseMultipleAddresses
// to parse the address list.
mcol.Add(list);
foreach (MailAddress m in mcol) {
// ...
}
} catch {
// We don't want this to throw any exceptions even if the
// address list is malformed.
}
from s22.imap.
But i want (my app) to be informed about what failed and what the original data was. That might easily be done with a event that can be subscribed to?
Also we want to know about all cases that do not work and handle that, instead of depending on exceptions.
(I'm taught that depending on exceptions is bad practice)
from s22.imap.
How do you handle an illegal or deliberately malformed address, though? There's no way to magically fix it, so ParseMultipleAddresses throws an exception, which it should in my opinion. In such a case I much prefer swallowing the exception and hand the user a MailMessage instance with the respective field left empty to letting the exception bubble up.
from s22.imap.
That's why i suggested a Event.
The user can both get a MailMessage instance and also information about the incorrectly parsed address.
But i also prefer the function to catch the invalid formats before it have become exceptions.
from s22.imap.
I have a similar problem but in my case the character that causes the exception is ',' )not ';' (may because it is from a french sever ) this character is at the end of the 'To' adresses
I see that the character ',' is not handled in the ParseAddressList in the MessageBuilder.cs
I have made a pull request #68
list = list.TrimEnd(',');
Exception thrown :{An invalid character was found in the mail header: ','
at System.Net.Mail.DotAtomReader.ReadReverse(String data, Int32 index)
at System.Net.Mail.MailAddressParser.ParseDomain(String data, Int32& index)
at System.Net.Mail.MailAddressParser.ParseAddress(String data, Boolean expectMultipleAddresses, Int32& index)
at System.Net.Mail.MailAddressParser.ParseMultipleAddresses(String data)
at System.Net.Mail.MailAddressCollection.ParseValue(String addresses)
at System.Net.Mail.MailAddressCollection.Add(String addresses)
at S22.Imap.MessageBuilder.ParseAddressList(String list)
at S22.Imap.MessageBuilder.SetAddressFields(MailMessage m, NameValueCollection header)
at S22.Imap.MessageBuilder.FromHeader(String text)
at S22.Imap.MessageBuilder.FromMIME822(String text)
at S22.Imap.ImapClient.GetMessage(UInt32 uid, FetchOptions options, Boolean seen, String mailbox)
at S22.Imap.ImapClient.GetMessage(UInt32 uid, Boolean seen, String mailbox)
at MyProjects.Helpers.EmailHelper.GetMessages() in e:\MyProjects\OMR-Projects\Helpers\EmailHelper.cs:line 28}
from s22.imap.
Semi-colons are perfectly legal tokens in rfc822 group addresses. The fact that System.Net.Mail's MailAddress[Collection] parser doesn't handle them isn't a surprise since it's not really meant to be used to handle real-world mail, it's just a half-assed solution for sending mail, not receiving it.
Anyway, MimeKit's InternetAddressList Parse() and TryParse() methods handle this.
from s22.imap.
Related Issues (20)
- Error “xm007 bad command argument 11” while marking outlook email as read from Scheduler not at manual run
- How can check the status of Message if is seen or unseen
- Attachments from iPhones don't always populate the Attachments collection HOT 2
- SearchCondition.SentSince seems not working HOT 1
- Low file size attachment is not found
- No type "Mailmessage" in Mono C# .net core linux application HOT 1
- Where are attachments after downloading ?
- Network connection lost while retrieving a mail message HOT 1
- SCRAM-SHA-1-PLUS + SCRAM-SHA-224(-PLUS) + SCRAM-SHA-256(-PLUS) + SCRAM-SHA-384(-PLUS) + SCRAM-SHA-512(-PLUS) + SCRAM-SHA3-512(-PLUS) supports
- Move this project to new dev team?
- inline file
- Intermittent freezing on Search
- DeleteMessage doesn't delete the message
- Documentation is not available - 404 error HOT 1
- xm002 NO SELECT Unsafe Login. Please contact [email protected] for help HOT 1
- Can not login to gmail HOT 1
- Connection doesn't restart after disruption to internet connection
- How to read email with 'Reply-To' position email account
- Is there a save option for the message itself as a *.eml file
- Error getting value from 'ReadTimeout' on 'System.IO.MemoryStream'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s22.imap.