Fix escaping data for new collapse UI widget

This commit is contained in:
Ilia Rostovtsev
2020-11-29 22:31:57 +03:00
parent b2c41bfa26
commit 9ed2c11389
2 changed files with 13 additions and 7 deletions

View File

@@ -85,7 +85,8 @@ if ($r == 0) {
print &ui_details({
'title' => $text{'syslog_desc2'},
'content' => &text('index_emsg',"<tt>$rout</tt>"),
'class' =>'error'});
'class' =>'error',
'html' => 1}, 1);
}
if ($access{'stop'} && &is_mysql_local()) {
@@ -109,7 +110,7 @@ elsif ($r == -1) {
'title' => $text{'syslog_desc2'},
'content' => &text('index_emsg',"<tt>$rout</tt>"),
'class' => 'error',
'open' => 'open'}) . "<br>";
'html' => 1}, 1) . "<br>";
}
print &ui_form_start("login.cgi", "post");

View File

@@ -2723,7 +2723,7 @@ if (defined(&theme_ui_line_break_double)) {
return "<br><br data-x-br>\n";
}
=head2 ui_details(title, content, class)
=head2 ui_details(Config, Opened)
Creates a disclosure widget in which information is visible only when
the widget is toggled into an "open" state.
@@ -2731,16 +2731,21 @@ the widget is toggled into an "open" state.
=cut
sub ui_details
{
my ($c) = @_;
my ($c, $o) = @_;
if (defined(&theme_ui_details)) {
return &theme_ui_details(@_);
}
my $rv;
$c->{'class'} = "class=\"$c->{'class'}\"" if($c->{'class'});
$rv = "<details $c->{'class'} $c->{'open'}>";
if (!$c->{'html'}) {
$c->{'title'} = &html_escape($c->{'title'});
$c->{'content'} = &html_escape($c->{'content'});
}
$c->{'class'} = " class=\"@{[&quote_escape($c->{'class'})]}\"" if($c->{'class'});
$o = ' open' if ($o);
$rv = "<details$c->{'class'}$o>";
$rv .= "<summary>$c->{'title'}</summary>";
$rv .= "$c->{'content'}";
$rv .= "<span>$c->{'content'}</span>";
$rv .= "</details>";
return $rv;
}