From d8c3b43a5e31f8032bee4d08fd9db79cea6ac4a7 Mon Sep 17 00:00:00 2001 From: Ketan Kulkarni Date: Tue, 24 Sep 2013 15:53:55 +0530 Subject: [PATCH 1/7] test commit --- members/member.pl | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/members/member.pl b/members/member.pl index 78b762f..c72368b 100755 --- a/members/member.pl +++ b/members/member.pl @@ -197,3 +197,4 @@ $template->param( ); output_html_with_http_headers $input, $cookie, $template->output; +print $member; -- 1.7.1 From f4dcddf3a2dd2e8bba3a0173531ae923103505d4 Mon Sep 17 00:00:00 2001 From: Ketan Kulkarni Date: Thu, 26 Sep 2013 14:35:54 +0530 Subject: [PATCH 2/7] double utf8 encoding fix .. second try --- C4/ItemType.pm | 4 ++-- C4/Search.pm | 1 + C4/Templates.pm | 16 +++++++++++++--- members/member.pl | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/C4/ItemType.pm b/C4/ItemType.pm index ad253a7..4aa23d4 100644 --- a/C4/ItemType.pm +++ b/C4/ItemType.pm @@ -81,7 +81,7 @@ sub all { for ( @{$dbh->selectall_arrayref( "SELECT * FROM itemtypes ORDER BY description", { Slice => {} })} ) { - utf8::encode($_->{description}); + utf8::upgrade($_->{description}); push @itypes, $class->new($_); } return @itypes; @@ -105,7 +105,7 @@ sub get { "SELECT * FROM itemtypes WHERE itemtype = ?", undef, $itemtype ); if ( $data->{description} ) { - utf8::encode($data->{description}); + utf8::upgrade($data->{description}); } return $class->new($data); } diff --git a/C4/Search.pm b/C4/Search.pm index 0453b91..ba559e8 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -574,6 +574,7 @@ sub getRecords { { # Sanitize the link value : parenthesis, question and exclamation mark will cause errors with CCL + utf8::decode($one_facet); my $facet_link_value = $one_facet; $facet_link_value =~ s/[()!?¡¿؟]/ /g; diff --git a/C4/Templates.pm b/C4/Templates.pm index 21604fc..b25bf0f 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -124,7 +124,15 @@ sub output { utf8_hashref($vars->{$k}); } else { - utf8::encode($vars->{$k}) if utf8::is_utf8($vars->{$k}); + if(utf8::is_utf8($vars->{$k})){ + utf8::upgrade($vars->{$k}); + } + else{ + ## this should not be needed (ideally :-) + ## this is included because, somewhere the input + ## is not getting utf8-decoded + utf8::decode($vars->{$k}); + } } } my $data; @@ -145,7 +153,8 @@ sub utf8_arrayref { utf8_hashref($element); next; } - utf8::encode($element) if utf8::is_utf8($element); + + utf8::upgrade($element) if utf8::is_utf8($element); } } @@ -160,7 +169,8 @@ sub utf8_hashref { utf8_hashref($hashref->{$key}); next; } - utf8::encode($hashref->{$key}) if utf8::is_utf8($hashref->{$key}); + + utf8::upgrade($hashref->{$key}) if utf8::is_utf8($hashref->{$key}); } } diff --git a/members/member.pl b/members/member.pl index c72368b..3efe1c4 100755 --- a/members/member.pl +++ b/members/member.pl @@ -85,6 +85,7 @@ if ($AddPatronLists=~/code/){ } my $member=$input->param('member') || ''; + my $orderbyparams=$input->param('orderby') || ''; my @orderby; if ($orderbyparams){ @@ -197,4 +198,3 @@ $template->param( ); output_html_with_http_headers $input, $cookie, $template->output; -print $member; -- 1.7.1 From 3a3e5e8f4fcebcc2e8bdad6c8b409a7e1cc0173b Mon Sep 17 00:00:00 2001 From: Ketan Kulkarni Date: Thu, 26 Sep 2013 14:38:29 +0530 Subject: [PATCH 3/7] minor formatting updates --- C4/Templates.pm | 2 -- members/member.pl | 1 - 2 files changed, 0 insertions(+), 3 deletions(-) diff --git a/C4/Templates.pm b/C4/Templates.pm index b25bf0f..b4f68ca 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -153,7 +153,6 @@ sub utf8_arrayref { utf8_hashref($element); next; } - utf8::upgrade($element) if utf8::is_utf8($element); } } @@ -169,7 +168,6 @@ sub utf8_hashref { utf8_hashref($hashref->{$key}); next; } - utf8::upgrade($hashref->{$key}) if utf8::is_utf8($hashref->{$key}); } } diff --git a/members/member.pl b/members/member.pl index 3efe1c4..78b762f 100755 --- a/members/member.pl +++ b/members/member.pl @@ -85,7 +85,6 @@ if ($AddPatronLists=~/code/){ } my $member=$input->param('member') || ''; - my $orderbyparams=$input->param('orderby') || ''; my @orderby; if ($orderbyparams){ -- 1.7.1 From f5455927bea40ed52411c4233cceb8d9f2547e21 Mon Sep 17 00:00:00 2001 From: Ketan Kulkarni Date: Thu, 26 Sep 2013 16:35:38 +0530 Subject: [PATCH 4/7] enhancement to the previous patch related to utf8 double encoding --- C4/Members.pm | 1 - C4/Search.pm | 3 +-- C4/Templates.pm | 10 +--------- members/member.pl | 3 +++ 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 7ac69df..d1c42a8 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -282,7 +282,6 @@ sub Search { $searchtype = "exact"; } $searchtype ||= "start_with"; - return SearchInTable( "borrowers", $filter, $orderby, $limit, $columns_out, $search_on_fields, $searchtype ); } diff --git a/C4/Search.pm b/C4/Search.pm index ba559e8..16ca641 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1206,7 +1206,6 @@ sub parseQuery { $query .= " #$modifier"; } } - $query_desc = $query; $query_desc =~ s/\s+/ /g; if ( C4::Context->preference("QueryWeightFields") ) { @@ -1252,7 +1251,6 @@ sub buildQuery { my $query_desc; ( $operators, $operands, $indexes, $limits, $sort_by, $scan, $lang, $query_desc) = parseQuery($operators, $operands, $indexes, $limits, $sort_by, $scan, $lang); - # dereference my @operators = $operators ? @$operators : (); my @indexes = $indexes ? @$indexes : (); @@ -1607,6 +1605,7 @@ sub buildQuery { warn "LIMIT DESC:" . $limit_desc; warn "---------\nLeave buildQuery\n---------"; } + utf8::decode($query_desc); return ( undef, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, $limit_desc, diff --git a/C4/Templates.pm b/C4/Templates.pm index b4f68ca..342240c 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -124,15 +124,7 @@ sub output { utf8_hashref($vars->{$k}); } else { - if(utf8::is_utf8($vars->{$k})){ - utf8::upgrade($vars->{$k}); - } - else{ - ## this should not be needed (ideally :-) - ## this is included because, somewhere the input - ## is not getting utf8-decoded - utf8::decode($vars->{$k}); - } + utf8::upgrade($vars->{$k}) if utf8::is_utf8($vars->{$k}); } } my $data; diff --git a/members/member.pl b/members/member.pl index 78b762f..a30b01b 100755 --- a/members/member.pl +++ b/members/member.pl @@ -49,6 +49,9 @@ my ($template, $loggedinuser, $cookie) my $theme = $input->param('theme') || "default"; my $patron = $input->Vars; +my $tmp_member = $patron->{member}; +utf8::decode($tmp_member); +$patron->{member} = $tmp_member; foreach (keys %$patron){ delete $$patron{$_} unless($$patron{$_}); } -- 1.7.1 From f2520938987894bed8498ec6e267da5eaba8e64c Mon Sep 17 00:00:00 2001 From: Ketan Kulkarni Date: Fri, 27 Sep 2013 17:07:42 +0530 Subject: [PATCH 5/7] added ENCODING=>utf8 to new-> --- C4/Templates.pm | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/C4/Templates.pm b/C4/Templates.pm index 342240c..46433fc 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -62,6 +62,7 @@ sub new { my $template = Template->new( { EVAL_PERL => 1, ABSOLUTE => 1, + ENCODING => 'utf8', PLUGIN_BASE => 'Koha::Template::Plugin', COMPILE_EXT => C4::Context->config('template_cache_dir')?'.ttc':'', COMPILE_DIR => C4::Context->config('template_cache_dir')?C4::Context->config('template_cache_dir'):'',, -- 1.7.1 From ba0c068d0c3ab469b546d82ac15f7064ece94121 Mon Sep 17 00:00:00 2001 From: Ketan Kulkarni Date: Fri, 27 Sep 2013 17:10:13 +0530 Subject: [PATCH 6/7] added space which is there in master --- C4/Members.pm | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index d1c42a8..7ac69df 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -282,6 +282,7 @@ sub Search { $searchtype = "exact"; } $searchtype ||= "start_with"; + return SearchInTable( "borrowers", $filter, $orderby, $limit, $columns_out, $search_on_fields, $searchtype ); } -- 1.7.1 From ab2e58b58d88e397ae326a2093c19050ba6f26a0 Mon Sep 17 00:00:00 2001 From: Ketan Kulkarni Date: Sun, 29 Sep 2013 11:31:30 +0530 Subject: [PATCH 7/7] added utf8::decode for ms_query --- opac/opac-search.pl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 2854da6..0fa470a 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -96,7 +96,6 @@ my $template_name; my $template_type = 'basic'; my @params = $cgi->param("limit"); - my $format = $cgi->param("format") || ''; my $build_grouped_results = C4::Context->preference('OPACGroupResults'); if ($format =~ /(rss|atom|opensearchdescription)/) { @@ -395,6 +394,7 @@ $template->{VARS}->{querystring} = join(' ', @operands); if ($operands[0] && !$operands[1]) { my $ms_query = $operands[0]; $ms_query =~ s/ #\S+//; + utf8::decode($ms_query); $template->param(ms_value => $ms_query); } -- 1.7.1