mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-26 03:58:45 +08:00
fix update file parsing
This commit is contained in:
@@ -24,25 +24,11 @@ namespace mRemoteNG.App.Update
|
||||
|
||||
public string ChangeLog => _changeLog;
|
||||
|
||||
public bool IsGetUpdateInfoRunning
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_getUpdateInfoThread == null) return false;
|
||||
return _getUpdateInfoThread.IsAlive;
|
||||
}
|
||||
}
|
||||
public bool IsGetUpdateInfoRunning => _getUpdateInfoThread != null && _getUpdateInfoThread.IsAlive;
|
||||
|
||||
private bool IsGetChangeLogRunning
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_getChangeLogThread == null) return false;
|
||||
return _getChangeLogThread.IsAlive;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsDownloadUpdateRunning => (_downloadUpdateWebClient != null);
|
||||
private bool IsGetChangeLogRunning => _getChangeLogThread != null && _getChangeLogThread.IsAlive;
|
||||
|
||||
public bool IsDownloadUpdateRunning => (_downloadUpdateWebClient != null);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -161,7 +147,7 @@ namespace mRemoteNG.App.Update
|
||||
#region Private Methods
|
||||
private WebClient CreateWebClient()
|
||||
{
|
||||
WebClient webClient = new WebClient();
|
||||
var webClient = new WebClient();
|
||||
webClient.Headers.Add("user-agent", GeneralAppInfo.UserAgent);
|
||||
webClient.Proxy = _webProxy;
|
||||
return webClient;
|
||||
@@ -247,7 +233,6 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
Authenticode updateAuthenticode = new Authenticode(_currentUpdateInfo.UpdateFilePath)
|
||||
{
|
||||
// I'm guessing that this is going to prevent 1.72 from auto updating to 1.74+
|
||||
RequireThumbprintMatch = true,
|
||||
ThumbprintToMatch = _currentUpdateInfo.CertificateThumbprint
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace mRemoteNG.App.Update
|
||||
{
|
||||
@@ -23,36 +24,33 @@ namespace mRemoteNG.App.Update
|
||||
// ReSharper disable once MemberCanBePrivate.Global
|
||||
public void FromString(string content)
|
||||
{
|
||||
// ReSharper restore MemberCanBePrivate.Local
|
||||
if (string.IsNullOrEmpty(content))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
char[] lineSeparators = { '\n', '\r' };
|
||||
char[] keyValueSeparators = { ':', '=' };
|
||||
char[] commentCharacters = { '#', ';', '\'' };
|
||||
if (string.IsNullOrEmpty(content)) return;
|
||||
|
||||
string[] lines = content.Split(lineSeparators.ToString().ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string line in lines)
|
||||
char[] keyValueSeparators = { ':', '=' };
|
||||
char[] commentCharacters = { '#', ';', '\'' };
|
||||
|
||||
using (var sr = new StringReader(content))
|
||||
{
|
||||
string line;
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
{
|
||||
string trimmedLine = line.Trim();
|
||||
var trimmedLine = line.Trim();
|
||||
if (trimmedLine.Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (trimmedLine.Substring(0, 1).IndexOfAny(commentCharacters.ToString().ToCharArray()) != -1)
|
||||
if (trimmedLine.Substring(0, 1).IndexOfAny(commentCharacters) != -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string[] parts = trimmedLine.Split(keyValueSeparators.ToString().ToCharArray(), 2);
|
||||
var parts = trimmedLine.Split(keyValueSeparators, 2);
|
||||
if (parts.Length != 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string key = Convert.ToString(parts[0].Trim());
|
||||
string value = Convert.ToString(parts[1].Trim());
|
||||
var key = parts[0].Trim();
|
||||
var value = parts[1].Trim();
|
||||
|
||||
_items.Add(key, value);
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ namespace mRemoteNG.App.Update
|
||||
|
||||
public static UpdateInfo FromString(string input)
|
||||
{
|
||||
UpdateInfo newInfo = new UpdateInfo();
|
||||
var newInfo = new UpdateInfo();
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
newInfo.IsValid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateFile updateFile = new UpdateFile(input);
|
||||
var updateFile = new UpdateFile(input);
|
||||
newInfo.Version = updateFile.GetVersion("Version");
|
||||
newInfo.DownloadAddress = updateFile.GetUri("dURL");
|
||||
newInfo.ChangeLogAddress = updateFile.GetUri("clURL");
|
||||
|
||||
@@ -42,18 +42,18 @@ namespace mRemoteNG.UI.Window
|
||||
lblLatestVersion.Text = Language.strVersion;
|
||||
lblLatestVersionLabel.Text = $"{Language.strAvailableVersion}:";
|
||||
}
|
||||
|
||||
public void btnCheckForUpdate_Click(Object sender, EventArgs e)
|
||||
|
||||
private void btnCheckForUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
CheckForUpdate();
|
||||
}
|
||||
|
||||
public void btnDownload_Click(Object sender, EventArgs e)
|
||||
|
||||
private void btnDownload_Click(object sender, EventArgs e)
|
||||
{
|
||||
DownloadUpdate();
|
||||
}
|
||||
|
||||
public void pbUpdateImage_Click(Object sender, EventArgs e)
|
||||
|
||||
private void pbUpdateImage_Click(object sender, EventArgs e)
|
||||
{
|
||||
Uri linkUri = pbUpdateImage.Tag as Uri;
|
||||
if (linkUri == null || linkUri.IsFile || linkUri.IsUnc || linkUri.IsLoopback)
|
||||
|
||||
Reference in New Issue
Block a user