Update samy.ps1
This commit is contained in:
12
samy.ps1
12
samy.ps1
@@ -1328,6 +1328,12 @@ function Send-JSON {
|
||||
if (-not $Context -or -not $Context.Response) {
|
||||
return
|
||||
}
|
||||
|
||||
# If caller gave us $null, reply with an empty array instead of blowing up
|
||||
if ($null -eq $Object) {
|
||||
$Object = @()
|
||||
}
|
||||
|
||||
$json = $Object | ConvertTo-Json -Depth 5
|
||||
$bytes = [Text.Encoding]::UTF8.GetBytes($json)
|
||||
$Context.Response.ContentType = 'application/json'
|
||||
@@ -1794,6 +1800,12 @@ function Invoke-GetPrinters {
|
||||
# NOTE: We never log the actual password
|
||||
$printers = Get-SamyClientListFromServer -Uri $uri -Password $password
|
||||
|
||||
# 🔹 EXTRA SAFETY: never pass $null to Send-JSON
|
||||
if ($null -eq $printers) {
|
||||
Write-LogHybrid "Get-SamyClientListFromServer returned `$null; sending empty JSON array." Warning Printers -LogToEvent
|
||||
$printers = @()
|
||||
}
|
||||
|
||||
# Return raw objects as JSON; JS will filter/group
|
||||
Send-JSON $Context $printers
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user