View | Details | Raw Unified | Return to bug 6554
Collapse All | Expand All

(-)a/C4/Context.pm (-1 / +3 lines)
Lines 1104-1110 set_userenv is called in Auth.pm Link Here
1104
1104
1105
#'
1105
#'
1106
sub set_userenv {
1106
sub set_userenv {
1107
    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $persona)= @_;
1107
    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $persona)=
1108
    map { utf8::decode($_); $_ } # CGI::Session doesn't handle utf-8, so we decode it here
1109
    @_;
1108
    my $var=$context->{"activeuser"} || '';
1110
    my $var=$context->{"activeuser"} || '';
1109
    my $cell = {
1111
    my $cell = {
1110
        "number"     => $usernum,
1112
        "number"     => $usernum,
(-)a/C4/ItemType.pm (-1 / +1 lines)
Lines 81-87 sub all { Link Here
81
    for ( @{$dbh->selectall_arrayref(
81
    for ( @{$dbh->selectall_arrayref(
82
        "SELECT * FROM itemtypes ORDER BY description", { Slice => {} })} )
82
        "SELECT * FROM itemtypes ORDER BY description", { Slice => {} })} )
83
    {
83
    {
84
        utf8::encode($_->{description});
84
#        utf8::encode($_->{description});
85
        push @itypes, $class->new($_);
85
        push @itypes, $class->new($_);
86
    }
86
    }
87
    return @itypes;
87
    return @itypes;
(-)a/C4/Output.pm (+1 lines)
Lines 308-313 sub output_with_http_headers { Link Here
308
}
308
}
309
309
310
sub output_html_with_http_headers {
310
sub output_html_with_http_headers {
311
    binmode( STDOUT, ":encoding(utf8)" );
311
    my ( $query, $cookie, $data, $status ) = @_;
312
    my ( $query, $cookie, $data, $status ) = @_;
312
    output_with_http_headers( $query, $cookie, $data, 'html', $status );
313
    output_with_http_headers( $query, $cookie, $data, 'html', $status );
313
}
314
}
(-)a/C4/Search.pm (-11 / +14 lines)
Lines 484-489 sub getRecords { Link Here
484
                    # not an index scan
484
                    # not an index scan
485
                    else {
485
                    else {
486
                        $record = $results[ $i - 1 ]->record($j)->raw();
486
                        $record = $results[ $i - 1 ]->record($j)->raw();
487
                        utf8::decode( $record );
487
488
488
                        # warn "RECORD $j:".$record;
489
                        # warn "RECORD $j:".$record;
489
                        $results_hash->{'RECORDS'}[$j] = $record;
490
                        $results_hash->{'RECORDS'}[$j] = $record;
Lines 501-506 sub getRecords { Link Here
501
                        for ( my $j = 0 ; $j < $jmax ; $j++ ) {
502
                        for ( my $j = 0 ; $j < $jmax ; $j++ ) {
502
                            my $render_record =
503
                            my $render_record =
503
                              $results[ $i - 1 ]->record($j)->render();
504
                              $results[ $i - 1 ]->record($j)->render();
505
                            utf8::decode($render_record);
504
                            my @used_datas = ();
506
                            my @used_datas = ();
505
                            foreach my $tag ( @{ $facet->{tags} } ) {
507
                            foreach my $tag ( @{ $facet->{tags} } ) {
506
508
Lines 714-719 sub pazGetRecords { Link Here
714
        for (my $i = 0; $i < $count; $i++) {
716
        for (my $i = 0; $i < $count; $i++) {
715
            # FIXME -- may need to worry about diacritics here
717
            # FIXME -- may need to worry about diacritics here
716
            my $rec = $paz->record($recid, $i);
718
            my $rec = $paz->record($recid, $i);
719
            utf8::decode( $rec );
717
            push @{ $result_group->{'RECORDS'} }, $rec;
720
            push @{ $result_group->{'RECORDS'} }, $rec;
718
        }
721
        }
719
722
Lines 1290-1306 sub buildQuery { Link Here
1290
        if ( @limits ) {
1293
        if ( @limits ) {
1291
            $q .= ' and '.join(' and ', @limits);
1294
            $q .= ' and '.join(' and ', @limits);
1292
        }
1295
        }
1293
        return ( undef, $q, $q, "q=ccl=".uri_escape($q), $q, '', '', '', '', 'ccl' );
1296
        return ( undef, $q, $q, "q=ccl=".uri_escape_utf8($q), $q, '', '', '', '', 'ccl' );
1294
    }
1297
    }
1295
    if ( $query =~ /^cql=/ ) {
1298
    if ( $query =~ /^cql=/ ) {
1296
        return ( undef, $', $', "q=cql=".uri_escape($'), $', '', '', '', '', 'cql' );
1299
        return ( undef, $', $', "q=cql=".uri_escape_utf8($'), $', '', '', '', '', 'cql' );
1297
    }
1300
    }
1298
    if ( $query =~ /^pqf=/ ) {
1301
    if ( $query =~ /^pqf=/ ) {
1299
        if ($query_desc) {
1302
        if ($query_desc) {
1300
            $query_cgi = "q=".uri_escape($query_desc);
1303
            $query_cgi = "q=".uri_escape_utf8($query_desc);
1301
        } else {
1304
        } else {
1302
            $query_desc = $';
1305
            $query_desc = $';
1303
            $query_cgi = "q=pqf=".uri_escape($');
1306
            $query_cgi = "q=pqf=".uri_escape_utf8($');
1304
        }
1307
        }
1305
        return ( undef, $', $', $query_cgi, $query_desc, '', '', '', '', 'pqf' );
1308
        return ( undef, $', $', $query_cgi, $query_desc, '', '', '', '', 'pqf' );
1306
    }
1309
    }
Lines 1472-1480 sub buildQuery { Link Here
1472
                        $query     .= " $operators[$i-1] ";
1475
                        $query     .= " $operators[$i-1] ";
1473
                        $query     .= " $index_plus " unless $indexes_set;
1476
                        $query     .= " $index_plus " unless $indexes_set;
1474
                        $query     .= " $operand";
1477
                        $query     .= " $operand";
1475
                        $query_cgi .= "&op=".uri_escape($operators[$i-1]);
1478
                        $query_cgi .= "&op=".uri_escape_utf8($operators[$i-1]);
1476
                        $query_cgi .= "&idx=".uri_escape($index) if $index;
1479
                        $query_cgi .= "&idx=".uri_escape_utf8($index) if $index;
1477
                        $query_cgi .= "&q=".uri_escape($operands[$i]) if $operands[$i];
1480
                        $query_cgi .= "&q=".uri_escape_utf8($operands[$i]) if $operands[$i];
1478
                        $query_desc .=
1481
                        $query_desc .=
1479
                          " $operators[$i-1] $index_plus $operands[$i]";
1482
                          " $operators[$i-1] $index_plus $operands[$i]";
1480
                    }
1483
                    }
Lines 1484-1491 sub buildQuery { Link Here
1484
                        $query      .= " and ";
1487
                        $query      .= " and ";
1485
                        $query      .= "$index_plus " unless $indexes_set;
1488
                        $query      .= "$index_plus " unless $indexes_set;
1486
                        $query      .= "$operand";
1489
                        $query      .= "$operand";
1487
                        $query_cgi  .= "&op=and&idx=".uri_escape($index) if $index;
1490
                        $query_cgi  .= "&op=and&idx=".uri_escape_utf8($index) if $index;
1488
                        $query_cgi  .= "&q=".uri_escape($operands[$i]) if $operands[$i];
1491
                        $query_cgi  .= "&q=".uri_escape_utf8($operands[$i]) if $operands[$i];
1489
                        $query_desc .= " and $index_plus $operands[$i]";
1492
                        $query_desc .= " and $index_plus $operands[$i]";
1490
                    }
1493
                    }
1491
                }
1494
                }
Lines 1497-1504 sub buildQuery { Link Here
1497
                    $query .= " $index_plus " unless $indexes_set;
1500
                    $query .= " $index_plus " unless $indexes_set;
1498
                    $query .= $operand;
1501
                    $query .= $operand;
1499
                    $query_desc .= " $index_plus $operands[$i]";
1502
                    $query_desc .= " $index_plus $operands[$i]";
1500
                    $query_cgi  .= "&idx=".uri_escape($index) if $index;
1503
                    $query_cgi  .= "&idx=".uri_escape_utf8($index) if $index;
1501
                    $query_cgi  .= "&q=".uri_escape($operands[$i]) if $operands[$i];
1504
                    $query_cgi  .= "&q=".uri_escape_utf8($operands[$i]) if $operands[$i];
1502
                    $previous_operand = 1;
1505
                    $previous_operand = 1;
1503
                }
1506
                }
1504
            }    #/if $operands
1507
            }    #/if $operands
(-)a/C4/Templates.pm (-42 / +2 lines)
Lines 67-72 sub new { Link Here
67
            COMPILE_DIR => C4::Context->config('template_cache_dir')?C4::Context->config('template_cache_dir'):'',,
67
            COMPILE_DIR => C4::Context->config('template_cache_dir')?C4::Context->config('template_cache_dir'):'',,
68
            INCLUDE_PATH => \@includes,
68
            INCLUDE_PATH => \@includes,
69
            FILTERS => {},
69
            FILTERS => {},
70
            ENCODING => 'utf8', # templates don't have BOM, see Template::FAQ
70
        }
71
        }
71
    ) or die Template->error();
72
    ) or die Template->error();
72
    my $self = {
73
    my $self = {
Lines 114-170 sub output { Link Here
114
        C4::Context->preference('opaclayoutstylesheet');
115
        C4::Context->preference('opaclayoutstylesheet');
115
116
116
    # add variables set via param to $vars for processing
117
    # add variables set via param to $vars for processing
117
    # and clean any utf8 mess
118
    for my $k ( keys %{ $self->{VARS} } ) {
118
    for my $k ( keys %{ $self->{VARS} } ) {
119
        $vars->{$k} = $self->{VARS}->{$k};
119
        $vars->{$k} = $self->{VARS}->{$k};
120
        if (ref($vars->{$k}) eq 'ARRAY'){
121
            utf8_arrayref($vars->{$k});
122
        }
123
        elsif (ref($vars->{$k}) eq 'HASH'){
124
            utf8_hashref($vars->{$k});
125
        }
126
        else {
127
            utf8::encode($vars->{$k}) if utf8::is_utf8($vars->{$k});
128
        }
129
    }
120
    }
130
    my $data;
121
    my $data;
131
#    binmode( STDOUT, ":utf8" );
132
    $template->process( $self->filename, $vars, \$data )
122
    $template->process( $self->filename, $vars, \$data )
133
      || die "Template process failed: ", $template->error();
123
      || die "Template process failed: ", $template->error();
134
    return $data;
124
    return $data;
135
}
125
}
136
126
137
sub utf8_arrayref {
127
138
    my $arrayref = shift;
139
    foreach my $element (@$arrayref){
140
        if (ref($element) eq 'ARRAY'){
141
            utf8_arrayref($element);
142
            next;
143
        }
144
        if (ref($element) eq 'HASH'){
145
            utf8_hashref($element);
146
            next;
147
        }
148
        utf8::encode($element) if utf8::is_utf8($element);
149
    }        
150
}         
151
152
sub utf8_hashref {
153
    my $hashref = shift;
154
    for my $key (keys %{$hashref}){
155
        if (ref($hashref->{$key}) eq 'ARRAY'){
156
            utf8_arrayref($hashref->{$key});
157
            next;
158
        }
159
        if (ref($hashref->{$key}) eq 'HASH'){
160
            utf8_hashref($hashref->{$key});
161
            next;
162
        }
163
        utf8::encode($hashref->{$key}) if utf8::is_utf8($hashref->{$key});
164
    }
165
}
166
        
167
        
168
# FIXME - this is a horrible hack to cache
128
# FIXME - this is a horrible hack to cache
169
# the current known-good language, temporarily
129
# the current known-good language, temporarily
170
# put in place to resolve bug 4403.  It is
130
# put in place to resolve bug 4403.  It is
(-)a/admin/preferences.pl (+1 lines)
Lines 34-39 use File::Spec; Link Here
34
use IO::File;
34
use IO::File;
35
use YAML::Syck qw();
35
use YAML::Syck qw();
36
$YAML::Syck::ImplicitTyping = 1;
36
$YAML::Syck::ImplicitTyping = 1;
37
$YAML::Syck::ImplicitUnicode = 1; # force utf-8 for preference encoding
37
our $lang;
38
our $lang;
38
39
39
# use Smart::Comments;
40
# use Smart::Comments;
(-)a/admin/z3950servers.pl (-1 / +1 lines)
Lines 21-27 Link Here
21
21
22
use strict;
22
use strict;
23
use warnings;
23
use warnings;
24
use CGI;
24
use CGI qw( -utf8 );
25
use C4::Context;
25
use C4::Context;
26
use C4::Auth;
26
use C4::Auth;
27
use C4::Output;
27
use C4::Output;
(-)a/authorities/authorities-home.pl (-1 / +1 lines)
Lines 125-131 if ( $op eq "do_search" ) { Link Here
125
    # next/previous would not work anymore
125
    # next/previous would not work anymore
126
126
127
    # construction of the url of each page
127
    # construction of the url of each page
128
    my $value_url = uri_escape($value);
128
    my $value_url = uri_escape_utf8($value);
129
    my $base_url = "authorities-home.pl?"
129
    my $base_url = "authorities-home.pl?"
130
      ."marclist=$marclist"
130
      ."marclist=$marclist"
131
      ."&amp;and_or=$and_or"
131
      ."&amp;and_or=$and_or"
(-)a/catalogue/search.pl (-1 / +1 lines)
Lines 154-160 use C4::Branch; # GetBranches Link Here
154
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
154
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
155
# create a new CGI object
155
# create a new CGI object
156
# FIXME: no_undef_params needs to be tested
156
# FIXME: no_undef_params needs to be tested
157
use CGI qw('-no_undef_params');
157
use CGI qw( -no_undef_params -utf8 );
158
my $cgi = new CGI;
158
my $cgi = new CGI;
159
159
160
my ($template,$borrowernumber,$cookie);
160
my ($template,$borrowernumber,$cookie);
(-)a/cataloguing/addbiblio.pl (-1 / +1 lines)
Lines 880-886 if ( $op eq "addbiblio" ) { Link Here
880
            .'&frameworkcode='.$frameworkcode
880
            .'&frameworkcode='.$frameworkcode
881
            .'&circborrowernumber='.$fa_circborrowernumber
881
            .'&circborrowernumber='.$fa_circborrowernumber
882
            .'&branch='.$fa_branch
882
            .'&branch='.$fa_branch
883
            .'&barcode='.uri_escape($fa_barcode)
883
            .'&barcode='.uri_escape_utf8($fa_barcode)
884
            .'&stickyduedate='.$fa_stickyduedate
884
            .'&stickyduedate='.$fa_stickyduedate
885
            .'&duedatespec='.$fa_duedatespec
885
            .'&duedatespec='.$fa_duedatespec
886
		);
886
		);
(-)a/cataloguing/additem.pl (-1 / +1 lines)
Lines 517-523 if ($op eq "additem") { Link Here
517
        print $input->redirect(
517
        print $input->redirect(
518
           '/cgi-bin/koha/circ/circulation.pl?'
518
           '/cgi-bin/koha/circ/circulation.pl?'
519
           .'borrowernumber='.$fa_circborrowernumber
519
           .'borrowernumber='.$fa_circborrowernumber
520
           .'&barcode='.uri_escape($fa_barcode)
520
           .'&barcode='.uri_escape_utf8($fa_barcode)
521
           .'&duedatespec='.$fa_duedatespec
521
           .'&duedatespec='.$fa_duedatespec
522
           .'&stickyduedate=1'
522
           .'&stickyduedate=1'
523
        );
523
        );
(-)a/cataloguing/z3950_search.pl (-1 / +1 lines)
Lines 20-26 Link Here
20
20
21
use strict;
21
use strict;
22
use warnings;
22
use warnings;
23
use CGI;
23
use CGI qw( -utf8 );
24
24
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Output;
26
use C4::Output;
(-)a/members/member.pl (-1 / +1 lines)
Lines 27-33 use strict; Link Here
27
#use warnings; FIXME - Bug 2505
27
#use warnings; FIXME - Bug 2505
28
use C4::Auth;
28
use C4::Auth;
29
use C4::Output;
29
use C4::Output;
30
use CGI;
30
use CGI qw( -utf8 );
31
use C4::Members;
31
use C4::Members;
32
use C4::Branch;
32
use C4::Branch;
33
use C4::Category;
33
use C4::Category;
(-)a/opac/opac-search.pl (-2 / +2 lines)
Lines 60-66 use Business::ISBN; Link Here
60
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
60
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
61
# create a new CGI object
61
# create a new CGI object
62
# FIXME: no_undef_params needs to be tested
62
# FIXME: no_undef_params needs to be tested
63
use CGI qw('-no_undef_params');
63
use CGI qw( -no_undef_params -utf8 );
64
my $cgi = new CGI;
64
my $cgi = new CGI;
65
65
66
my $branch_group_limit = $cgi->param("branch_group_limit");
66
my $branch_group_limit = $cgi->param("branch_group_limit");
Lines 652-658 for (my $i=0;$i<@servers;$i++) { Link Here
652
                $newsearchcookie = $cgi->cookie(
652
                $newsearchcookie = $cgi->cookie(
653
                            -name => 'KohaOpacRecentSearches',
653
                            -name => 'KohaOpacRecentSearches',
654
                            # We uri_escape the whole freezed structure so we're sure we won't have any encoding problems
654
                            # We uri_escape the whole freezed structure so we're sure we won't have any encoding problems
655
                            -value => uri_escape(freeze(\@recentSearches)),
655
                            -value => uri_escape_utf8(freeze(\@recentSearches)),
656
                            -expires => ''
656
                            -expires => ''
657
                );
657
                );
658
                $cookie = [$cookie, $newsearchcookie];
658
                $cookie = [$cookie, $newsearchcookie];
(-)a/reports/guided_reports.pl (-1 / +1 lines)
Lines 665-671 elsif ($phase eq 'Run this report'){ Link Here
665
            my $totpages = int($total/$limit) + (($total % $limit) > 0 ? 1 : 0);
665
            my $totpages = int($total/$limit) + (($total % $limit) > 0 ? 1 : 0);
666
            my $url = "/cgi-bin/koha/reports/guided_reports.pl?reports=$report_id&amp;phase=Run%20this%20report&amp;limit=$limit";
666
            my $url = "/cgi-bin/koha/reports/guided_reports.pl?reports=$report_id&amp;phase=Run%20this%20report&amp;limit=$limit";
667
            if (@sql_params) {
667
            if (@sql_params) {
668
                $url = join('&amp;sql_params=', $url, map { URI::Escape::uri_escape($_) } @sql_params);
668
                $url = join('&amp;sql_params=', $url, map { URI::Escape::uri_escape_utf8($_) } @sql_params);
669
            }
669
            }
670
            $template->param(
670
            $template->param(
671
                'results' => \@rows,
671
                'results' => \@rows,
(-)a/reserve/renewscript.pl (-1 / +1 lines)
Lines 127-133 foreach my $barcode (@barcodes) { Link Here
127
# redirection to the referrer page
127
# redirection to the referrer page
128
#
128
#
129
if ( $input->param('destination') eq "circ" ) {
129
if ( $input->param('destination') eq "circ" ) {
130
    $cardnumber = uri_escape($cardnumber);
130
    $cardnumber = uri_escape_utf8($cardnumber);
131
    print $input->redirect( '/cgi-bin/koha/circ/circulation.pl?findborrower='
131
    print $input->redirect( '/cgi-bin/koha/circ/circulation.pl?findborrower='
132
          . $cardnumber
132
          . $cardnumber
133
          . $failedrenews
133
          . $failedrenews
(-)a/serials/routing-preview.pl (-1 / +1 lines)
Lines 127-133 $routingnotes =~ s/\n/\<br \/\>/g; Link Here
127
$template->param(
127
$template->param(
128
    title => $subs->{'bibliotitle'},
128
    title => $subs->{'bibliotitle'},
129
    issue => $issue,
129
    issue => $issue,
130
    issue_escaped => URI::Escape::uri_escape($issue),
130
    issue_escaped => URI::Escape::uri_escape_utf8($issue),
131
    subscriptionid => $subscriptionid,
131
    subscriptionid => $subscriptionid,
132
    memberloop => $memberloop,
132
    memberloop => $memberloop,
133
    routingnotes => $routingnotes,
133
    routingnotes => $routingnotes,
(-)a/serials/routing.pl (-2 / +1 lines)
Lines 62-68 if($op eq 'add'){ Link Here
62
if($op eq 'save'){
62
if($op eq 'save'){
63
    my $sth = $dbh->prepare('UPDATE serial SET routingnotes = ? WHERE subscriptionid = ?');
63
    my $sth = $dbh->prepare('UPDATE serial SET routingnotes = ? WHERE subscriptionid = ?');
64
    $sth->execute($notes,$subscriptionid);
64
    $sth->execute($notes,$subscriptionid);
65
    my $urldate = URI::Escape::uri_escape($date_selected);
65
    my $urldate = URI::Escape::uri_escape_utf8($date_selected);
66
    print $query->redirect("routing-preview.pl?subscriptionid=$subscriptionid&issue=$urldate");
66
    print $query->redirect("routing-preview.pl?subscriptionid=$subscriptionid&issue=$urldate");
67
}
67
}
68
68
69
- 

Return to bug 6554