85495

UriFormatException when using %40 instead of @ in mailto: protocol

Question:

I am writing a default mail client to handle when someone clicks mailto:bob@example.com<br />

craigslist mailto links have the form mailto:bob%40example.com<br /> I get an exception when this is used.<br /> here is some simple code to repeat the problem in c#<br />

System.Uri u1 = new Uri(@"mailto:bob@ms.com"); // 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:<br /> shoudn't mailto:bob%40example.com be a valid uri question 2:<br /> if it is an invalid uri then how is outlook not crashing on it.<br />

I am using visual studio 2012<br />

Answer1:

RFC 6068 (<a href="http://www.ietf.org/rfc/rfc6068.txt" rel="nofollow">http://www.ietf.org/rfc/rfc6068.txt</a>), which defines the mailto protocol, does <strong>not</strong> specify that %40 is a valid syntax to replace @ as a username/domain separator.

It does specify that if a <em>username</em> contains a @, such as in the case hello@you@domain.com, you can use %40 to escape it to hello%40you@domain.com. 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...

Recommend

  • How to do numerical multiple integral (more than triple)?
  • GLSL : accessing framebuffer to get RGB and change it
  • proper way to swap unions?
  • AWK Multiple Field Separators and Variables
  • How to send multiple JMS messages in blocks (each in a new transaction)
  • Django ManyToMany filtering by set size or member in the set
  • GHC Generics: How to write an implementation of (:+:) that converts sum types from/to integers?
  • Multiple device inserted notifications
  • sqlite3_wal_checkpoint_v2 always returns SQL_BUSY
  • How can I associate a custom URL protocol with a ClickOnce app?
  • How do I write an item to a DynamoDb with the AWS DynamoDB DocumentClient?
  • How to make Plotly chart with year mapped to line color and months on x-axis
  • Visual Studio 2008 and JavaScript brackets formatting
  • Cosmos DB succeeds and fails on randomly on the same query, saying they are cross partition when the
  • css calendar - td background diagonal split - two colors
  • GRPC and types import error in App Engine Datastore
  • Color time-series based on column values in pandas
  • Flex items with same property values are rendering in different sizes
  • CodeIgniter URI Parameter is partially bypassing an “if” statement
  • How to retrieve information from antrun back to maven?
  • Bash if statement with multiple conditions
  • RxJava debounce by arbitrary value
  • Android Google Maps API v2 start navigation
  • Automatically associate new Sonar project with custom quality profile and quality gate
  • System.InvalidCastException: Specified cast is not valid
  • HTTP/2 streams vs HTTP/1.1 connections
  • Dialing with Intent.ACTION_CALL stopps at # in phone number
  • Meteor helpers not available in Angular template
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Menu Color Fade on Hover with Jquery
  • Build own AppleScript numerical error handling
  • bootstrap to use multiple ng-app
  • SetUp method failed while running tests from teamcity
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • How to get icons for entities from eclipse?
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • Getting error when using KSoap library to consume .NET web services
  • Turn off referential integrity in Derby? is it possible?
  • JaxB to read class hierarchy
  • java string with new operator and a literal