Skip to content

Commit

Permalink
Handle exceptions in IsUri
Browse files Browse the repository at this point in the history
Any exception means it’s not a Uri.
  • Loading branch information
da2x committed Jul 29, 2017
1 parent 49918b6 commit 57c7114
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions EdgeDeflector/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,19 @@ private static void RegisterProtocolHandler()

static bool IsUri(string uristring)
{
Uri uri = new Uri(uristring);
return uri.IsWellFormedOriginalString();
try
{
Uri uri = new Uri(uristring);
return uri.IsWellFormedOriginalString();
}
catch (System.UriFormatException)
{
return false;
}
catch (ArgumentNullException)
{
return false;
}
}

static bool IsHttpUri(string uri)
Expand All @@ -112,7 +123,7 @@ static bool IsMsEdgeUri(string uri)

static bool IsNewCortanaURI(string uri)
{
return (uri.Contains("launchContext1=Microsoft.Windows.Cortana"));
return uri.Contains("launchContext1=Microsoft.Windows.Cortana");
}

static string GetURIFromCortanaLink(string uri)
Expand Down Expand Up @@ -177,7 +188,7 @@ static void Main(string[] args)
OpenUri(uri);
}
// Install when running without argument
else if (args.Equals(null) || args.Length == 0)
else if (args.Length == 0 || args.Equals(null))
{
if (!IsElevated())
{
Expand Down

0 comments on commit 57c7114

Please sign in to comment.