Bugzilla – Attachment 132027 Details for
Bug 22223
Item url double-encode when parameter is an encoded URL
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22223: Try to not double encoded URIs in items.uri
Bug-22223-Try-to-not-double-encoded-URIs-in-itemsu.patch (text/plain), 6.69 KB, created by
Jonathan Druart
on 2022-03-22 14:47:29 UTC
(
hide
)
Description:
Bug 22223: Try to not double encoded URIs in items.uri
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-03-22 14:47:29 UTC
Size:
6.69 KB
patch
obsolete
>From 1c6334f7544e50e13544ded00cf8ee1ffecb3dfb Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sat, 4 May 2019 11:21:42 -0400 >Subject: [PATCH] Bug 22223: Try to not double encoded URIs in items.uri >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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 > >Signed-off-by: Séverine Queune <severine.queune@bulac.fr> >--- > Koha/Template/Plugin/Filter.pm | 32 +++++++++++++++++++ > .../prog/en/modules/catalogue/detail.tt | 9 ++++-- > .../bootstrap/en/modules/opac-detail.tt | 7 ++-- > 3 files changed, 44 insertions(+), 4 deletions(-) > 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 00000000000..9dbd16022c9 >--- /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/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index cae2357f356..4ef5a74ef6a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -2,6 +2,7 @@ > [% USE Asset %] > [% USE Koha %] > [% USE KohaDates %] >+[% USE Filter %] > [% USE KohaPlugins %] > [% USE AuthorisedValues %] > [% USE Branches %] >@@ -519,12 +520,16 @@ Note that permanent location is a code, and location may be an authval. > [% IF ( itemdata_uri ) %] > [% IF item.uri.split(' \| ').size > 1 %] > <td class="uri"> >- [% FOREACH uri IN item.uri.split(' \| ') %]<a href="[% uri | url %]">[% uri | html %]</a><br>[% END %] >+ [% FOREACH uri IN item.uri.split(' \| ') ~%] >+ [%~ uri_url_filtered = BLOCK %][% uri | url ~%][% END %] >+ <a href="[% Filter.no_double_encode( uri_url_filtered ) | $raw %]">[% uri | html %]</a><br> >+ [%~ END %] > </td> > [% ELSE %] > <td class="uri"> > [% IF item.uri %] >- <a href="[% item.uri | url %]">[% IF Koha.Preference('URLLinkText') %][% Koha.Preference('URLLinkText') | html %][% ELSE %]Link to resource[% END %]</a> >+ [%~ uri_url_filtered = BLOCK %][% item.uri | url ~%][% END %] >+ <a href="[% Filter.no_double_encode( uri_url_filtered ) | $raw %]">[% IF Koha.Preference('URLLinkText') %][% Koha.Preference('URLLinkText') | html %][% ELSE %]Link to resource[% END %]</a> > [% END %] > </td> > [% END %] >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 f6dc6014a25..5031cd6d19e 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 TablesSettings %] > [% USE AuthorisedValues %] >@@ -1298,14 +1299,16 @@ > [% IF trackclicks == 'track' || trackclicks == 'anonymous' %] > <a target="[% target_attr | html %]" rel="[% rel_attr | html %]" href="/cgi-bin/koha/tracklinks.pl?uri=[% uri | uri %]&biblionumber=[% biblio.biblionumber | html %]&itemnumber=[% ITEM_RESULT.itemnumber | html %]" property="url">[% uri | html %]</a> > [% ELSE %] >- <a target="[% target_attr | html %]" rel="[% rel_attr | html %]" href="[% uri | url %]" property="url">[% uri | html %]</a> >+ [% uri_url_filtered = BLOCK %][% uri | url %][% END %] >+ <a target="[% target_attr | html %]" rel="[% rel_attr | html %]" href="[% Filter.no_double_encode( uri_url_filtered ) | $raw %]" property="url">[% uri | html %]</a> > [% END %] > [% END %] > [% ELSE %] > [% IF trackclicks == 'track' || trackclicks == 'anonymous' %] > <a target="[% target_attr | html %]" rel="[% rel_attr | html %]" href="/cgi-bin/koha/tracklinks.pl?uri=[% ITEM_RESULT.uri | uri %]&biblionumber=[% biblio.biblionumber | html %]&itemnumber=[% ITEM_RESULT.itemnumber | html %]" property="url"> > [% ELSE %] >- <a target="[% target_attr | html %]" rel="[% rel_attr | html %]" href="[% ITEM_RESULT.uri | url %]" property="url"> >+ [% uri_url_filtered = BLOCK %][% ITEM_RESULT.uri | url %][% END %] >+ <a target="[% target_attr | html %]" rel="[% rel_attr | html %]" href="[% Filter.no_double_encode( uri_url_filtered ) | $raw %]" property="url"> > [% END %] > [% IF Koha.Preference('URLLinkText') %][% Koha.Preference('URLLinkText') | html %][% ELSE %]Link to resource[% END %] > </a> >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22223
:
89352
|
126174
|
132027
|
133567
|
133578
|
133589
|
133590
|
170485
|
170577
|
174101
|
174104
|
174105