[Modify] Move port checks

This commit is contained in:
sta
2016-06-02 16:43:14 +09:00
parent e61253baea
commit ca31d86c1a
3 changed files with 29 additions and 26 deletions

View File

@@ -87,7 +87,12 @@ namespace WebSocketSharp.Net
if (!addr.IsLocal ())
throw new HttpListenerException (87, "Includes an invalid host.");
var port = pref.Port;
int port;
if (!Int32.TryParse (pref.Port, out port))
throw new HttpListenerException (87, "Includes an invalid port.");
if (!port.IsPortNumber ())
throw new HttpListenerException (87, "Includes an invalid port.");
var path = pref.Path;
if (path.IndexOf ('%') != -1)
@@ -146,7 +151,12 @@ namespace WebSocketSharp.Net
if (!addr.IsLocal ())
return;
var port = pref.Port;
int port;
if (!Int32.TryParse (pref.Port, out port))
return;
if (!port.IsPortNumber ())
return;
var path = pref.Path;
if (path.IndexOf ('%') != -1)