fix: Replace broken .Split() with -split operator in Restore module selection

The previous implementation used .Split(',', ';', ' ') which
causes PowerShell to match the wrong .NET overload Split(string, Int32),
interpreting ';' as a count parameter and throwing a System.Int32
conversion error.

Replaced with native PowerShell -split operator using regex character
class [,; ] which correctly splits on comma, semicolon, or space.

Fixes: Restore Mode -> Manual Selection crash on any input
Reported-by: KatCat2
This commit is contained in:
NexusOne23 2026-01-07 18:27:32 +01:00
parent 74b73eda81
commit 8435dbe97b

View file

@ -75,11 +75,11 @@ function Write-Step {
$symbol = switch ($Status) {
"SUCCESS" { "[+]"; $color = "Green" }
"ERROR" { "[-]"; $color = "Red" }
"ERROR" { "[-]"; $color = "Red" }
"WARNING" { "[!]"; $color = "Yellow" }
"INFO" { "[>]"; $color = "Cyan" }
"WAIT" { "[.]"; $color = "Gray" }
default { "[ ]"; $color = "White" }
"INFO" { "[>]"; $color = "Cyan" }
"WAIT" { "[.]"; $color = "Gray" }
default { "[ ]"; $color = "White" }
}
Write-ColorText $symbol -Color $color -NoNewline
@ -356,7 +356,8 @@ function Show-BackupList {
# Force result to array to handle single-session case correctly
if (Test-Path $backupPath) {
$sessions = @(Get-BackupSessions -BackupDirectory $backupPath)
} else {
}
else {
$sessions = @()
}
}
@ -382,8 +383,8 @@ function Show-BackupList {
try {
$age = (Get-Date) - $session.Timestamp
$ageStr = if ($age.TotalHours -lt 1) { "$([math]::Round($age.TotalMinutes)) minutes ago" }
elseif ($age.TotalDays -lt 1) { "$([math]::Round($age.TotalHours)) hours ago" }
else { "$([math]::Round($age.TotalDays)) days ago" }
elseif ($age.TotalDays -lt 1) { "$([math]::Round($age.TotalHours)) hours ago" }
else { "$([math]::Round($age.TotalDays)) days ago" }
}
catch {
$ageStr = "unknown age"
@ -795,7 +796,7 @@ function Invoke-RestoreWorkflow {
if ([string]::IsNullOrWhiteSpace($modeInput)) { $modeInput = "A" }
$modeInput = $modeInput.Trim().ToUpper()
if ($modeInput -in @('A','M')) {
if ($modeInput -in @('A', 'M')) {
$restoreMode = $modeInput
break
}
@ -818,7 +819,7 @@ function Invoke-RestoreWorkflow {
}
$indices = @()
foreach ($token in $moduleInput.Split(',', ';', ' ')) {
foreach ($token in ($moduleInput -split '[,; ]')) {
if (-not [string]::IsNullOrWhiteSpace($token)) {
$parsed = 0
if ([int]::TryParse($token.Trim(), [ref]$parsed)) {
@ -837,7 +838,7 @@ function Invoke-RestoreWorkflow {
}
foreach ($i in $indices) {
$selectedModuleNames += $availableModules[$i-1].name
$selectedModuleNames += $availableModules[$i - 1].name
}
}
}