mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 14:07:46 +08:00
Normalize digit-only KB IDs to include KB prefix
Co-authored-by: Kvarkas <3611964+Kvarkas@users.noreply.github.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user