mirror of
https://github.com/NexusOne23/noid-privacy.git
synced 2026-02-08 04:24:29 +01:00
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:
parent
74b73eda81
commit
8435dbe97b
1 changed files with 11 additions and 10 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue