From 06a3d440689b0eec1f2d3e288913f2070cc06731 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 6 Nov 2020 11:41:35 +0100 Subject: [PATCH] Bug 24633: URI escape the search term --- plugins/plugins-home.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/plugins-home.pl b/plugins/plugins-home.pl index f9d72b885d..0b4a46217d 100755 --- a/plugins/plugins-home.pl +++ b/plugins/plugins-home.pl @@ -23,6 +23,7 @@ use CGI qw ( -utf8 ); use JSON qw(from_json); use LWP::Simple qw(get); +use URI::Escape qw( uri_escape_utf8 ); use Koha::Plugins; use C4::Auth; @@ -72,9 +73,10 @@ if ($plugins_enabled) { $repos = { repo => [ $repos->{repo} ] }; } + my $plugin_search_uri = uri_escape_utf8( $plugin_search ); foreach my $r ( @{ $repos->{repo} } ) { if ( $r->{service} eq 'github' ) { - my $url = "https://api.github.com/search/repositories?q=$plugin_search+user:$r->{org_name}+in:name,description"; + my $url = "https://api.github.com/search/repositories?q=$plugin_search_uri+user:$r->{org_name}+in:name,description"; my $response = from_json( get($url) ); foreach my $result ( @{ $response->{items} } ) { next unless $result->{name} =~ /^koha-plugin-/; @@ -91,7 +93,8 @@ if ($plugins_enabled) { } elsif ( $r->{service} eq 'gitlab' ) { my $org_name = $r->{org_name}; - my $url = "https://gitlab.com/api/v4/groups/$org_name/projects?with_issues_enabled=no\&with_merge_requests_enabled=no\&with_shared=no\&include_subgroups=yes\&search=koha-plugin+$plugin_search"; + my $url = "https://gitlab.com/api/v4/groups/$org_name/projects?with_issues_enabled=no\&with_merge_requests_enabled=no\&with_shared=no\&include_subgroups=yes\&search=koha-plugin+$plugin_search_uri"; + warn $url; my $response = from_json( get($url) ); foreach my $result ( @{ $response } ) { next unless $result->{name} =~ /^koha-plugin-/; -- 2.20.1