codemonkey85 / isemail

Automatically exported from code.google.com/p/isemail
0 stars 0 forks source link

Out of Range Exception thrown in C# validate function when entire sub domain section is in parens #29

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run UI tester.
2. Paste in "bob@example.(foo).com"
3. System.ArgumentOutOfRangeException was unhandled is thrown at line 736 
because elementLength is zero.

What is the expected output? What do you see instead?
No exepction thrown and email flagged as invalid.

What version of the product are you using? On what operating system?
Most recent C# code.

Please provide any additional information below.

At line 732 I've added an if statement to handle the zero length string:
  if (elementLength == 0) return false;

Original issue reported on code.google.com by ratb...@gmail.com on 1 Feb 2012 at 9:25

GoogleCodeExporter commented 9 years ago
Additionally I can't find anywhere that documents that parentheses should be 
allowed in domain names. So after making the change listed above 
bob@(foo)example.com valildates as a proper email address but none of the major 
emails services seem to allow it.

Can you point out where this is specified as legal.

Original comment by ratb...@gmail.com on 2 Feb 2012 at 6:37

GoogleCodeExporter commented 9 years ago
Hi ratborg. I can answer the question about parentheses in domain names. They 
are not allowed in Mailboxes (RFC 5321) but in the message body, the addr-spec 
can have comments denoted by parentheses (RFC 5322). However, RFC 5322 also 
notes they SHOULD NOT be used around the @ sign in the address. 
http://tools.ietf.org/html/rfc5322#section-3.4.1 

So if you're validating an email address to use in the envelope of an SMTP 
message (the normal case) then parentheses are definitely not valid.

I think the C# code may be a little out of date but I don't maintain it myself.

Original comment by dominic....@gmail.com on 8 Feb 2012 at 6:30

GoogleCodeExporter commented 9 years ago

Original comment by dominic....@gmail.com on 8 Feb 2012 at 6:31

GoogleCodeExporter commented 9 years ago

Original comment by dominic....@gmail.com on 8 Feb 2012 at 6:31

GoogleCodeExporter commented 9 years ago

Original comment by dominic....@gmail.com on 8 Feb 2012 at 6:33