diff --git a/samy.ps1 b/samy.ps1
index fab10b3..a3e19e7 100644
--- a/samy.ps1
+++ b/samy.ps1
@@ -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 '<','<'
+ $s = $s -replace '>','>'
+ return $s
+ }
+
+ function Escape-HtmlText {
+ param([string]$s)
+ if ([string]::IsNullOrEmpty($s)) { return '' }
+ $s = $s -replace '&','&'
+ $s = $s -replace '<','<'
+ $s = $s -replace '>','>'
+ 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 = ""
+ $tooltipText = Escape-HtmlAttr $rawTooltip
+ $tooltipAttr = if ([string]::IsNullOrWhiteSpace($tooltipText)) { '' } else { " title=""$tooltipText""" }
+
+ $labelText = Escape-HtmlText ([string]$_.Label)
+
+ $html = ""
if ($_.SubOptions) {
$subHtml = (