Scenario: An app that supports hyperlinks inside content. The app has code to execute the hyperlink that looks like this:
Process.Start(href); // href is the link, e.g. "http://www.google.com"
Question: The user can set arbitrary content in the string, and the app needs to sanitize it and disallow non-URLs such as "foo.exe" that might be local commands or executables. What is the "correct" way to do this? Note: we're not trying to do http blacklisting.
So far we're thinking of parsing this into a System.Uri, and checking that there is a non-empty uri Scheme, e.g. http://. But since this is a potential security issue (a user creating a document with a url and sending the document to someone else who clicks the url) we'd like to know what security experts recommend. For instance, a url with the file:// scheme may be problematic as well.
Edit: This is something I assume any app (browsers, word processors, editors, etc) that supports hyperlinks has to deal with. I'm interested in knowing what the standard behavior is.