Update samy.ps1

This commit is contained in:
2025-12-20 20:12:41 -05:00
parent ebba417ac4
commit a5ece0f5c3

View File

@@ -751,7 +751,7 @@ if (-not $Global:SamyTasks) {
throw "SAMY cannot continue: failed to load tasks from $Script:SamyTasksUrl"
}
#endregion building the Menus
#endregion building the Menu
#region Publish-Checkboxes
function Publish-Checkboxes {
@@ -760,6 +760,26 @@ if (-not $Global:SamyTasks) {
[string]$Column
)
function Escape-HtmlAttr {
param([string]$s)
if ([string]::IsNullOrEmpty($s)) { return '' }
$s = $s -replace '&','&'
$s = $s -replace '"','"'
$s = $s -replace '<','&lt;'
$s = $s -replace '>','&gt;'
return $s
}
function Escape-HtmlText {
param([string]$s)
if ([string]::IsNullOrEmpty($s)) { return '' }
$s = $s -replace '&','&amp;'
$s = $s -replace '<','&lt;'
$s = $s -replace '>','&gt;'
return $s
}
# Start with all tasks on the given page
$tasks = $Global:SamyTasks | Where-Object Page -EQ $Page
@@ -772,9 +792,18 @@ if (-not $Global:SamyTasks) {
$tasks |
ForEach-Object {
$taskId = $_.Id
$tooltip = " title='$($_.Tooltip)'"
$rawTooltip = if ($_.PSObject.Properties.Name -contains 'Tooltip' -and $_.Tooltip) {
[string]$_.Tooltip
} else {
[string]$_.Label
}
$html = "<label$tooltip><input type='checkbox' id='$taskId' name='$($_.Name)' data-column='$Column'> $($_.Label)</label>"
$tooltipText = Escape-HtmlAttr $rawTooltip
$tooltipAttr = if ([string]::IsNullOrWhiteSpace($tooltipText)) { '' } else { " title=""$tooltipText""" }
$labelText = Escape-HtmlText ([string]$_.Label)
$html = "<label$tooltipAttr><input type='checkbox' id='$taskId' name='$($_.Name)' data-column='$Column'> $labelText</label>"
if ($_.SubOptions) {
$subHtml = (