[Koha-bugs] [Bug 22223] Item url double-encode when parameter is an encoded URL

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Jul 30 07:45:33 CEST 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22223

--- Comment #20 from David Cook <dcook at prosentient.com.au> ---
Consider the following code:

#!/usr/bin/perl
use strict;
use warnings;
use URI::Escape;
use Template;
my $one = uri_unescape('https://www.google.com/url?q=https://buttercup.pw"');
my $two =
uri_unescape('https://www.google.com/url?q=https%3A%2F%2Fbuttercup.pw%22');
my $template = Template->new();
my $output;
$template->process( \*DATA, { one => $one, two => $two }, \$output );
warn $output;
__DATA__
[% one | url %]
[% two | url %]

Consider the output:
https://www.google.com/url?q=https://buttercup.pw%22
https://www.google.com/url?q=https://buttercup.pw%22

Actually... while that *looks* good... that's not necessarily correct, because
the "correct" URL is actually
https://www.google.com/url?q=https%3A%2F%2Fbuttercup.pw%22

That said... the end-target will uri_unescape the value of the "q" key anyway,
so it shouldn't matter. Plus the URI standard says you may choose not to
percent encode the query component due to usability concerns...

But our test cases might also be overly simplistic. I wonder if I have any
real-life complex URLs for digital resources laying around...

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list