Skip to content

Commit

Permalink
Merge branch '6.0/http-ascii-headers'
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrandtbuffalo committed Jan 6, 2025
2 parents 9b396fe + 8a12c96 commit d43e849
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 12 deletions.
2 changes: 1 addition & 1 deletion share/html/Elements/ShowSearch
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ my $title = loc(RT::SavedSearch->EscapeDescription($search->Description), $Proce
if ( $m->request_path =~ m{^/Views/} ) {
$event{triggerChanged} = 'every ' . $refresh_seconds . 's[checkRefreshState(this)]' if $refresh_seconds;
$event{widgetTitleChanged} = $title . ( $title_raw // '' );
$r->headers_out->{'HX-Trigger'} = JSON( \%event, utf8 => 1, );
$r->headers_out->{'HX-Trigger'} = JSON( \%event, ascii => 1, );
}

my @icon_links;
Expand Down
2 changes: 1 addition & 1 deletion share/html/Helpers/AssetUpdate
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ $r->headers_out->{'HX-Trigger'} = JSON(
actionsChanged => \@results,
map { $_ => '' } @events
},
utf8 => 1,
ascii => 1,
) if @events || @results;
</%INIT>
2 changes: 1 addition & 1 deletion share/html/Helpers/QuickCreate
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ if ( $ARGS{'QuickCreateSubmit'} ) {
{
actionsChanged => \@results
},
utf8 => 1,
ascii => 1,
) if @results;

}
Expand Down
4 changes: 2 additions & 2 deletions share/html/Helpers/SavedSearchOptions
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ if ( $SavedSearchId ) {
)
],
},
utf8 => 1,
ascii => 1,
);
}
else {
RT->Logger->error(
"Unable to update SearchRefreshIntervale from $ARGS{'SearchRefreshInterval'}: $msg"
);
$r->headers_out->{'HX-Trigger'} = JSON( { actionsChanged => [$msg], }, utf8 => 1, );
$r->headers_out->{'HX-Trigger'} = JSON( { actionsChanged => [$msg], }, ascii => 1, );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion share/html/Helpers/TicketUpdate
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ $r->headers_out->{'HX-Trigger'} = JSON(
actionsChanged => \@Actions,
map { $_ => '' } @events
},
utf8 => 1,
ascii => 1,
) if @events || @Actions;

</%INIT>
2 changes: 1 addition & 1 deletion share/html/Views/Asset/Title
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ my $asset = RT::Asset->new( $session{CurrentUser} );
$asset->Load($id);

my $title = loc( "Asset #[_1]: [_2]", $asset->Id, $asset->Name || '' );
$r->headers_out->{'HX-Trigger'} = JSON( { titleChanged => $title }, utf8 => 1, );
$r->headers_out->{'HX-Trigger'} = JSON( { titleChanged => $title }, ascii => 1, );
$m->out($m->interp->apply_escapes($title, 'h'));
$m->abort;
</%INIT>
Expand Down
2 changes: 1 addition & 1 deletion share/html/Views/Ticket/Title
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ my $ticket = RT::Ticket->new( $session{CurrentUser} );
$ticket->Load($id);

my $title = loc( "#[_1]: [_2]", $ticket->Id, $ticket->Subject || '' );
$r->headers_out->{'HX-Trigger'} = JSON( { titleChanged => $title }, utf8 => 1, );
$r->headers_out->{'HX-Trigger'} = JSON( { titleChanged => $title }, ascii => 1, );
$m->out($m->interp->apply_escapes($title, 'h'));
$m->abort;
</%INIT>
Expand Down
7 changes: 3 additions & 4 deletions share/static/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,7 @@ jQuery(function() {
document.body.addEventListener('actionsChanged', function(evt) {
if ( evt.detail.value ) {
for ( const action of evt.detail.value ) {
// Need to decode action that is UTF-8 encoded
jQuery.jGrowl(decodeURIComponent(escape(action)), { themeState: 'none' });
jQuery.jGrowl(action, { themeState: 'none' });
}

const history_container = document.querySelector('.history-container');
Expand Down Expand Up @@ -854,7 +853,7 @@ jQuery(function() {
});

document.body.addEventListener('titleChanged', function(evt) {
document.title = decodeURIComponent(escape(evt.detail.value));
document.title = evt.detail.value;
});

document.body.addEventListener('triggerChanged', function(evt) {
Expand All @@ -865,7 +864,7 @@ jQuery(function() {
document.body.addEventListener('widgetTitleChanged', function(evt) {
const title = evt.detail.elt.closest('div.titlebox').querySelector('.titlebox-title a');
if ( title ) {
title.innerHTML = decodeURIComponent(escape(evt.detail.value));
title.innerHTML = evt.detail.value;
}
});

Expand Down
26 changes: 26 additions & 0 deletions t/selenium/basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,32 @@ diag "test custom field unique values";
is( $ticket->FirstCustomFieldValue($cf), 456, 'CF value is set' );
}

{
$s->get_ok('/Prefs/AboutMe.html');
$s->submit_form_ok(
{
form_name => 'EditAboutMe',
fields => { Lang => 'zh-cn' },
},
'Update Language'
);

$s->text_contains( Encode::decode( 'UTF-8', '主页' ), 'Menu has changed to Chinese' );
$s->get_ok('/');
$s->text_contains( Encode::decode( 'UTF-8', '我拥有的前10份待处理申请单' ), 'Chinese title is correct' );

$s->get_ok('/Prefs/AboutMe.html');
$s->submit_form_ok(
{
form_name => 'EditAboutMe',
fields => { Lang => '' },
},
'Update Language'
);
$s->text_contains(q{Lang changed from 'zh-cn' to (no value)});

}

$s->logout;

done_testing;

0 comments on commit d43e849

Please sign in to comment.