From 13c461793281d8065ddc76e8aa5cff90dd061496 Mon Sep 17 00:00:00 2001 From: Karam Qubsi Date: Wed, 19 Jul 2017 00:06:48 +0800 Subject: [PATCH] Bug 18946 - Change language from external web fails MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit How to reproduce: 1. Get a multilingüal Koha like http://demo1.orex.es/cgi-bin/koha/opac-changelanguage.pl?language=en http://demo1.orex.es/cgi-bin/koha/opac-changelanguage.pl?language=es-ES 2. Copy that urls to any web page in an other domain -it must be in some host - and try to link to the spanish or english version,it will keep you in the same position. 3. Apply this patch and try again , everything should work fine . Signed-off-by: Hugo Agud Signed-off-by: Kyle M Hall Signed-off-by: Mason James --- opac/opac-changelanguage.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opac/opac-changelanguage.pl b/opac/opac-changelanguage.pl index 9c68ab46f6..689f4d4307 100755 --- a/opac/opac-changelanguage.pl +++ b/opac/opac-changelanguage.pl @@ -22,7 +22,10 @@ use CGI qw ( -utf8 ); my $query = new CGI; my $language = $query->param('language'); -my $url = $query->referer() || '/'; +# Detect where the user came from and save that url +my $requestedUrl = $query->url(-base => 1) ; +# Use referer url if it matches $requestedUrl else use $requestedUrl as the url . +my $url = $query->referer()=~$requestedUrl ? $query->referer() : $requestedUrl; # warn "Language : $query // $language // $url"; -- 2.39.5