Reputation: 1010
I am writing a default mail client to handle when someone clicks mailto:[email protected]
craigslist mailto links have the form mailto:bob%40example.com
I get an exception when this is used.
here is some simple code to repeat the problem in c#
System.Uri u1 = new Uri(@"mailto:[email protected]"); // ok so far
System.Uri u2 = new Uri(@"http://somewhere.foo/profile/username%40somewhere.foo"); // still ok
System.Uri u3 = new Uri(@"mailto:bob%40ms.com"); // crash here
question 1:
shoudn't mailto:bob%40example.com be a valid uri
question 2:
if it is an invalid uri then how is outlook not crashing on it.
I am using visual studio 2012
Upvotes: 1
Views: 1082
Reputation: 33139
RFC 6068 (http://www.ietf.org/rfc/rfc6068.txt), which defines the mailto protocol, does not specify that %40 is a valid syntax to replace @ as a username/domain separator.
It does specify that if a username contains a @, such as in the case hello@[email protected]
, you can use %40 to escape it to hello%[email protected]
. But nowhere does it state that hello%40domain.com
would be a valid mailto URI.
And if Microsoft decided to support it in Outlook, that still doesn't change the fact that the RFC, which is authoritative, doesn't define it -- so I'd say, Microsoft probably put it in for reasons of robustness, or maybe it's a side-effect of them parsing any URI for %xx syntax...
Upvotes: 4