From: Jeff Davis Date: Mon, 9 Nov 2020 21:59:59 +0000 (-0800) Subject: LP#1902965: HTML filter on OPAC search results and record display, with accordion X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ddbe3565dd5d2cda5ddd94279dcabb268d2edcf9;p=evergreen%2Ftadl.git LP#1902965: HTML filter on OPAC search results and record display, with accordion Signed-off-by: Jeff Davis Conflicts: Open-ILS/src/templates/opac/parts/record/contents.tt2 Open-ILS/src/templates/opac/parts/record/summary.tt2 Signed-off-by: Galen Charlton Signed-off-by: Jane Sandberg --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm index fdb0da5aca..064c9b8b32 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -6,6 +6,7 @@ use Time::HiRes qw/time sleep/; use List::MoreUtils qw(uniq); use HTML::TreeBuilder; use HTML::Element; +use HTML::Defang; use OpenSRF::Utils::Cache; use OpenSRF::Utils::Logger qw/$logger/; use OpenILS::Utils::CStoreEditor qw/:funcs/; @@ -13,6 +14,7 @@ use OpenILS::Utils::Fieldmapper; use OpenILS::Application::AppUtils; use OpenSRF::MultiSession; +my $defang = HTML::Defang->new; my $U = 'OpenILS::Application::AppUtils'; my $ro_object_subs; # cached subs @@ -155,7 +157,8 @@ sub init_ro_object_cache { my $nref = ref $node; if ($nref eq "HTML::Element") { $current_length += length $node->as_text(); - push(@html_strings, $node->as_HTML()); + my $escaped_html = $defang->defang($node->as_HTML()); + push(@html_strings, $escaped_html); } else { # Node is whitespace - handling this like regular simple text # doesn't like to play nice, so handling separately @@ -165,7 +168,7 @@ sub init_ro_object_cache { push(@html_strings, " $trunc_str"); $truncated = 1; } else { - push(@html_strings, $node); + push(@html_strings, $defang->defang($node)); } # Node is simple text } else { @@ -182,10 +185,12 @@ sub init_ro_object_cache { $nshort = substr $node, 0, $nloc; $nrest = substr $node, $nloc; } + $nshort = $defang->defang($nshort); + $nrest = $defang->defang($nrest); push(@html_strings, "$nshort $trunc_str $nrest"); $truncated = 1; } else { - push(@html_strings, $node); + push(@html_strings, $defang->defang($node)); } $current_length += length $node; } diff --git a/Open-ILS/src/templates/opac/parts/misc_util.tt2 b/Open-ILS/src/templates/opac/parts/misc_util.tt2 index ee600a1b36..fd7c0104e5 100644 --- a/Open-ILS/src/templates/opac/parts/misc_util.tt2 +++ b/Open-ILS/src/templates/opac/parts/misc_util.tt2 @@ -879,7 +879,7 @@ [% END -%] [% MACRO accordion(str, trunc_length, element) BLOCK; IF truncate_contents != 1; - str; + str | html; ELSE; UNLESS trunc_length; trunc_length = contents_truncate_length || 100; @@ -890,7 +890,9 @@ IF accordion_res.1; str = str _ " " _ l('Read More') _ ""; END; + str; + ELSE; + str | html; END; - str; END; END; %] diff --git a/Open-ILS/src/templates/opac/parts/record/body.tt2 b/Open-ILS/src/templates/opac/parts/record/body.tt2 index 2801670de8..11cb1ee9ee 100644 --- a/Open-ILS/src/templates/opac/parts/record/body.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/body.tt2 @@ -7,10 +7,10 @@ %]
[%- FOREACH link IN args.links.sameAs; %] - + [%- END; %] [%- FOREACH link IN args.links.exampleOfWork; %] - + [%- END; %] [%- INCLUDE "opac/parts/record/navigation.tt2" %] [%- IF ctx.bib_is_dead %] diff --git a/Open-ILS/src/templates/opac/parts/record/series.tt2 b/Open-ILS/src/templates/opac/parts/record/series.tt2 index a5ad664c8b..473e7544de 100644 --- a/Open-ILS/src/templates/opac/parts/record/series.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/series.tt2 @@ -12,7 +12,8 @@ BLOCK render_series; url = mkurl(ctx.opac_root _ '/results', { qtype=>'series', query=>search_term }, stop_parms.merge(expert_search_parms, general_search_parms, browse_search_parms, facet_search_parms) ); - series = '' _ s.$hl_field _ ' '; + filtered_hl_field = s.$hl_field | html; + series = '' _ filtered_hl_field _ ' '; results.push(series); END; ELSE; diff --git a/Open-ILS/src/templates/opac/parts/record/summary.tt2 b/Open-ILS/src/templates/opac/parts/record/summary.tt2 index d3aed58394..705411fff7 100644 --- a/Open-ILS/src/templates/opac/parts/record/summary.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/summary.tt2 @@ -40,7 +40,7 @@ isbnissn=attrs.issns.0; END; %] - + [% l('Image of item') %] @@ -76,7 +76,7 @@ + [% img_alt(l('Place Hold on [_1]', attrs.title)) | html %]/> [% l('Place Hold') %]
[%- END -%] @@ -86,14 +86,14 @@ + [% img_alt(l('Check Out [_1]', attrs.title)) | html %]/> [% l('Check Out E-Item') %] [%- END -%] @@ -108,7 +108,7 @@ rel="nofollow" vocab="" data-recid="[% ctx.bre_id %]" data-action="add" class="no-dec mylist_action [% IF ctx.mylist.grep('^' _ ctx.bre_id _ '$').size %]hidden[% END %]" - title="[% l("Add [_1] to basket", attrs.title) %]" rel="nofollow" vocab=""> + title="[% l("Add [_1] to basket", attrs.title) | html %]" rel="nofollow" vocab=""> [% l("Add to basket") %] @@ -116,7 +116,7 @@ rel="nofollow" vocab="" data-recid="[% ctx.bre_id %]" data-action="delete" class="mylist_action [% IF !ctx.mylist.grep('^' _ ctx.bre_id _ '$').size %]hidden[% END %]" - title="[% l("Remove [_1] from basket", attrs.title) %]" rel="nofollow" vocab=""> + title="[% l("Remove [_1] from basket", attrs.title) | html %]" rel="nofollow" vocab=""> [% l("Remove from basket") %] @@ -214,20 +214,25 @@ IF num_uris > 0;
[%- IF num_uris > 1 %]