Skip to content

Commit

Permalink
Fix potential parse error in UpdateManager (#12685)
Browse files Browse the repository at this point in the history
* Trim version string of non-numeric characters
* Fix comment
  • Loading branch information
Szpoti committed Mar 19, 2024
1 parent 8fa5f97 commit 8dadf3e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions WalletWasabi/Services/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ private async Task<(Version LatestVersion, string InstallerDownloadUrl, string I

string softwareVersion = jsonResponse["tag_name"]?.ToString() ?? throw new InvalidDataException("Endpoint gave back wrong json data or it's changed.");

// "tag_name" will have a 'v' at the beginning, needs to be removed.
Version githubVersion = new(softwareVersion[1..]);
// Make sure there are no non-numeric characters (besides '.') in the version string.
softwareVersion = string.Concat(softwareVersion.Where(c => char.IsDigit(c) || c == '.').ToArray());

Version githubVersion = new(softwareVersion);
Version shortGithubVersion = new(githubVersion.Major, githubVersion.Minor, githubVersion.Build);
if (targetVersion != shortGithubVersion)
{
Expand Down

0 comments on commit 8dadf3e

Please sign in to comment.