Do host name checking the same way in back- and frontend

This commit is contained in:
Hylke Bons 2011-05-22 19:08:14 +01:00
parent 748a54652f
commit 4d6ea9d707
2 changed files with 22 additions and 8 deletions

View file

@ -53,7 +53,7 @@ namespace SparkleLib {
public string Domain { public string Domain {
get { get {
Regex regex = new Regex (@"(@|://)([a-z0-9\.]+)/"); Regex regex = new Regex (@"(@|://)([a-z0-9\.]+)(/|:)");
Match match = regex.Match (Url); Match match = regex.Match (Url);
if (match.Success) if (match.Success)

View file

@ -968,12 +968,14 @@ namespace SparkleShare {
{ {
SparkleHelpers.DebugInfo ("Controller", "Formed URL: " + url); SparkleHelpers.DebugInfo ("Controller", "Formed URL: " + url);
// TODO: GetDomain method string host = GetHost (url);
string host = url.Substring (url.IndexOf ("@") + 1);
if (host.Contains (":")) if (String.IsNullOrEmpty (host)) {
host = host.Substring (0, host.IndexOf (":")); if (FolderFetchError != null)
else FolderFetchError ();
host = host.Substring (0, host.IndexOf ("/"));
return;
}
DisableHostKeyCheckingForHost (host); DisableHostKeyCheckingForHost (host);
@ -1053,7 +1055,19 @@ namespace SparkleShare {
Byte[] encoded_bytes = md5.ComputeHash (bytes); Byte[] encoded_bytes = md5.ComputeHash (bytes);
return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", ""); return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", "");
} }
private string GetHost (string url)
{
Regex regex = new Regex (@"(@|://)([a-z0-9\.]+)(/|:)");
Match match = regex.Match (url);
if (match.Success)
return match.Groups [2].Value;
else
return null;
}
// Checks whether there are any folders syncing and // Checks whether there are any folders syncing and
// quits if safe // quits if safe