From dca2517cf04a825f397bb1b894cadb7ed266bd0e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Dec 2025 12:19:35 +0000 Subject: [PATCH] Normalize digit-only KB IDs to include KB prefix Co-authored-by: Kvarkas <3611964+Kvarkas@users.noreply.github.com> --- .../InstalledWindowsUpdateChecker.cs | 10 ++++++++-- .../InstalledWindowsUpdateCheckerTests.cs | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/mRemoteNGInstaller/CustomActions/InstalledWindowsUpdateChecker.cs b/mRemoteNGInstaller/CustomActions/InstalledWindowsUpdateChecker.cs index 48e555be3..6df0d6f4c 100644 --- a/mRemoteNGInstaller/CustomActions/InstalledWindowsUpdateChecker.cs +++ b/mRemoteNGInstaller/CustomActions/InstalledWindowsUpdateChecker.cs @@ -94,8 +94,14 @@ namespace CustomActions if (!KbPattern.IsMatch(trimmedKb)) return string.Empty; - // Return the sanitized value (uppercased for consistency) - return trimmedKb.ToUpperInvariant(); + // Normalize to uppercase + var normalizedKb = trimmedKb.ToUpperInvariant(); + + // Ensure KB prefix is present (Win32_QuickFixEngineering always uses the KB prefix) + if (!normalizedKb.StartsWith("KB")) + normalizedKb = "KB" + normalizedKb; + + return normalizedKb; } } } \ No newline at end of file diff --git a/mRemoteNGTests/Installer/InstalledWindowsUpdateCheckerTests.cs b/mRemoteNGTests/Installer/InstalledWindowsUpdateCheckerTests.cs index aa47bc791..3be24dfd7 100644 --- a/mRemoteNGTests/Installer/InstalledWindowsUpdateCheckerTests.cs +++ b/mRemoteNGTests/Installer/InstalledWindowsUpdateCheckerTests.cs @@ -46,10 +46,10 @@ namespace mRemoteNGTests.Installer } [Test] - public void SanitizeKbId_ValidNumberOnly_ReturnsUppercased() + public void SanitizeKbId_ValidNumberOnly_ReturnsWithKbPrefix() { var result = InvokeSanitizeKbId("1234567"); - Assert.That(result, Is.EqualTo("1234567")); + Assert.That(result, Is.EqualTo("KB1234567")); } [Test] @@ -175,6 +175,20 @@ namespace mRemoteNGTests.Installer Assert.That(result, Is.EqualTo("HotFixID='KB1234567' OR HotFixID='KB7654321'")); } + [Test] + public void BuildWhereClause_DigitOnlyKb_AddsKbPrefix() + { + var result = InvokeBuildWhereClause(new[] { "1234567" }); + Assert.That(result, Is.EqualTo("HotFixID='KB1234567'")); + } + + [Test] + public void BuildWhereClause_MixedPrefixedAndDigitOnly_NormalizesAll() + { + var result = InvokeBuildWhereClause(new[] { "1234567", "KB7654321", "kb9999999" }); + Assert.That(result, Is.EqualTo("HotFixID='KB1234567' OR HotFixID='KB7654321' OR HotFixID='KB9999999'")); + } + #endregion #region Helper Methods