From 589a0bf73d707aea0d99aad7045365e08f9c281b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 4 May 2019 11:21:42 -0400 Subject: [PATCH] Bug 22223: Try to not double encoded URIs in items.uri This is just a POC and is not ready for inclusion (Filter.pm and naming need to be discussed). Test plan: Create 2 items, with uri: https://www.google.com/url?q=https://buttercup.pw https://www.google.com/url?q=https%3A%2F%2Fbuttercup.pw Go to the OPAC detail page of the bib record, see that the links are displayed how you entered them. Click on them and confirm that the uri/page is correct --- Koha/Template/Plugin/Filter.pm | 32 ++++++++++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 4 ++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Koha/Template/Plugin/Filter.pm diff --git a/Koha/Template/Plugin/Filter.pm b/Koha/Template/Plugin/Filter.pm new file mode 100644 index 0000000000..9dbd16022c --- /dev/null +++ b/Koha/Template/Plugin/Filter.pm @@ -0,0 +1,32 @@ +package Koha::Template::Plugin::Filter; + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Template::Plugin::Filter; +use base qw( Template::Plugin::Filter ); + +our $DYNAMIC = 1; + +sub no_double_encode { + my ( $self, $value ) = @_; + + $value =~ s/%25([0-9a-f]{2})/%$1/gi; + return $value; +} + +1; diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 7d25cde9db..4ce7af4bfa 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -3,6 +3,7 @@ [% USE Math %] [% USE Koha %] [% USE KohaDates %] +[% USE Filter %] [% USE Branches %] [% USE ColumnsSettings %] [% USE AuthorisedValues %] @@ -1335,7 +1336,8 @@ [% IF Koha.Preference("OPACURLOpenInNewWindow") %] [% ITEM_RESULT.uri | html %] [% ELSE %] - [% ITEM_RESULT.uri | html %] + [% uri_url_filtered = BLOCK %][% ITEM_RESULT.uri | url %][% END %] + [% uri_url_filtered | html %] [% END %] [% END %] [% END %] -- 2.11.0