From c8a6a0f69abebd1e49ffd4cc445f86f9748d2139 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 30 Sep 2026 16:53:05 +0200 Subject: [PATCH] Add label_html row option to ui_dl --- t/ui-lib-widgets.t | 2 ++ ui-lib.pl | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/t/ui-lib-widgets.t b/t/ui-lib-widgets.t index 001c63f42..2160f313a 100644 --- a/t/ui-lib-widgets.t +++ b/t/ui-lib-widgets.t @@ -176,6 +176,8 @@ unlike(main::ui_page_start({ 'scheme' => 'bogus"' }), { 'label' => 'Esc', 'value' => 'text' } ]); like($html, qr/]*>html<\/b><\/dd>/, 'array row value is HTML'); like($html, qr/<b>text<\/b>/, 'hash row value is escaped'); + like(main::ui_dl([ { 'label_html' => 'L', 'value' => 'v' } ]), + qr/]*>L<\/i><\/dt>/, 'hash row label_html is HTML'); like(main::ui_dl([ [ 'L', 'v', 'tip' ] ]), qr/ui_help/, 'help text uses the existing ui_help bubble'); } diff --git a/ui-lib.pl b/ui-lib.pl index 9d5d66e15..b43af3629 100755 --- a/ui-lib.pl +++ b/ui-lib.pl @@ -4897,6 +4897,8 @@ or a hash reference with keys : =item label - Plain label text. +=item label_html - Pre-built HTML for the label, used instead of label. + =item value - Plain value text, which will be escaped. =item value_html - Pre-built HTML for the value, used instead of value. @@ -4924,12 +4926,15 @@ foreach my $row (@$rows) { next if (!defined($row)); my ($label, $value, $help); if (ref($row) eq 'HASH') { - $label = &html_escape($row->{'label'}); + # Row given as named parts, escaped unless supplied as HTML + $label = defined($row->{'label_html'}) ? $row->{'label_html'} + : &html_escape($row->{'label'}); $value = defined($row->{'value_html'}) ? $row->{'value_html'} : &html_escape($row->{'value'}); $help = $row->{'help'}; } else { + # Row given as a [ label, value-html, help ] array $label = &html_escape($row->[0]); $value = defined($row->[1]) ? $row->[1] : ""; $help = $row->[2];