From 759ea40b22eb5b17fff4e4a8fb442127e8288257 Mon Sep 17 00:00:00 2001 From: lncubus Date: Sun, 19 Jun 2022 12:16:40 +0200 Subject: [PATCH] [OOBE]Hide "x64 ARM64 Installer Hash" lines in "What's New" (#18835) --- .../Settings.UI/OOBE/Views/OobeWhatsNew.xaml.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/settings-ui/Settings.UI/OOBE/Views/OobeWhatsNew.xaml.cs b/src/settings-ui/Settings.UI/OOBE/Views/OobeWhatsNew.xaml.cs index 0f7fe108d6..e4e59a9ba9 100644 --- a/src/settings-ui/Settings.UI/OOBE/Views/OobeWhatsNew.xaml.cs +++ b/src/settings-ui/Settings.UI/OOBE/Views/OobeWhatsNew.xaml.cs @@ -52,6 +52,12 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views DataContext = ViewModel; } + /// + /// Regex to remove installer hash sections from the release notes. + /// + private const string RemoveInstallerHashesRegex = @"((\r\n)+#+ installer hashes)?((\r\n)+#+( x64)?( arm64)? installer( SHA256)? hash(\r\n)+[0-9A-F]{64})+"; + private const RegexOptions RemoveInstallerHashesRegexOptions = RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant; + private static async Task GetReleaseNotesMarkdown() { string releaseNotesJSON = string.Empty; @@ -78,12 +84,13 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views StringBuilder releaseNotesHtmlBuilder = new StringBuilder(string.Empty); // Regex to remove installer hash sections from the release notes. - Regex removeHashRegex = new Regex(@"(\r\n)+#+ installer( SHA256)? hash(\r\n)+[0-9A-F]{64}", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); + Regex removeHashRegex = new Regex(RemoveInstallerHashesRegex, RemoveInstallerHashesRegexOptions); foreach (var release in latestReleases) { releaseNotesHtmlBuilder.AppendLine("# " + release.Name); - releaseNotesHtmlBuilder.AppendLine(removeHashRegex.Replace(release.ReleaseNotes, string.Empty)); + var notes = removeHashRegex.Replace(release.ReleaseNotes, string.Empty); + releaseNotesHtmlBuilder.AppendLine(notes); releaseNotesHtmlBuilder.AppendLine(" "); }