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

(-)a/C4/Context.pm (-1 / +3 lines)
Lines 1008-1014 set_userenv is called in Auth.pm Link Here
1008
1008
1009
#'
1009
#'
1010
sub set_userenv {
1010
sub set_userenv {
1011
    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter)= @_;
1011
    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter)= 
1012
	map { utf8::decode($_); $_ } # CGI::Session doesn't handle utf-8, so we decode it here
1013
	@_;
1012
    my $var=$context->{"activeuser"};
1014
    my $var=$context->{"activeuser"};
1013
    my $cell = {
1015
    my $cell = {
1014
        "number"     => $usernum,
1016
        "number"     => $usernum,
(-)a/C4/ItemType.pm (-1 / +1 lines)
Lines 78-84 sub all { Link Here
78
    for ( @{$dbh->selectall_arrayref(
78
    for ( @{$dbh->selectall_arrayref(
79
        "SELECT * FROM itemtypes ORDER BY description", { Slice => {} })} )
79
        "SELECT * FROM itemtypes ORDER BY description", { Slice => {} })} )
80
    {
80
    {
81
        utf8::encode($_->{description});
81
#        utf8::encode($_->{description});
82
        push @itypes, $class->new($_);
82
        push @itypes, $class->new($_);
83
    }
83
    }
84
    return @itypes;
84
    return @itypes;
(-)a/C4/Output.pm (+1 lines)
Lines 301-306 sub output_with_http_headers($$$$;$) { Link Here
301
    print $query->header($options), $data;
301
    print $query->header($options), $data;
302
}
302
}
303
303
304
    binmode( STDOUT, ":utf8" );
304
sub output_html_with_http_headers ($$$;$) {
305
sub output_html_with_http_headers ($$$;$) {
305
    my ( $query, $cookie, $data, $status ) = @_;
306
    my ( $query, $cookie, $data, $status ) = @_;
306
    output_with_http_headers( $query, $cookie, $data, 'html', $status );
307
    output_with_http_headers( $query, $cookie, $data, 'html', $status );
(-)a/C4/Search.pm (+4 lines)
Lines 267-272 sub SimpleSearch { Link Here
267
267
268
                for my $j ( $first_record..$last_record ) {
268
                for my $j ( $first_record..$last_record ) {
269
                    my $record = $tmpresults[ $i - 1 ]->record( $j-1 )->raw(); # 0 indexed
269
                    my $record = $tmpresults[ $i - 1 ]->record( $j-1 )->raw(); # 0 indexed
270
                    utf8::decode( $record );
270
                    push @{$results}, $record;
271
                    push @{$results}, $record;
271
                }
272
                }
272
            }
273
            }
Lines 458-463 sub getRecords { Link Here
458
                    # not an index scan
459
                    # not an index scan
459
                    else {
460
                    else {
460
                        $record = $results[ $i - 1 ]->record($j)->raw();
461
                        $record = $results[ $i - 1 ]->record($j)->raw();
462
                        utf8::decode( $record );
461
463
462
                        # warn "RECORD $j:".$record;
464
                        # warn "RECORD $j:".$record;
463
                        $results_hash->{'RECORDS'}[$j] = $record;
465
                        $results_hash->{'RECORDS'}[$j] = $record;
Lines 473-478 sub getRecords { Link Here
473
                    for my $facet ( @$facets ) {
475
                    for my $facet ( @$facets ) {
474
		                for ( my $j = 0 ; $j < $jmax ; $j++ ) {
476
		                for ( my $j = 0 ; $j < $jmax ; $j++ ) {
475
		                    my $render_record = $results[ $i - 1 ]->record($j)->render();
477
		                    my $render_record = $results[ $i - 1 ]->record($j)->render();
478
		                    utf8::decode($render_record);
476
                            my @used_datas = ();
479
                            my @used_datas = ();
477
                            foreach my $tag ( @{$facet->{tags}} ) {
480
                            foreach my $tag ( @{$facet->{tags}} ) {
478
                                # avoid first line
481
                                # avoid first line
Lines 635-640 sub pazGetRecords { Link Here
635
        for (my $i = 0; $i < $count; $i++) {
638
        for (my $i = 0; $i < $count; $i++) {
636
            # FIXME -- may need to worry about diacritics here
639
            # FIXME -- may need to worry about diacritics here
637
            my $rec = $paz->record($recid, $i);
640
            my $rec = $paz->record($recid, $i);
641
            utf8::decode( $rec );
638
            push @{ $result_group->{'RECORDS'} }, $rec;
642
            push @{ $result_group->{'RECORDS'} }, $rec;
639
        }
643
        }
640
644
(-)a/C4/Templates.pm (-42 / +2 lines)
Lines 65-70 sub new { Link Here
65
                "$htdocs/$theme/en/includes"
65
                "$htdocs/$theme/en/includes"
66
            ],
66
            ],
67
            FILTERS => {},
67
            FILTERS => {},
68
            ENCODING => 'utf8', # templates don't have BOM, see Template::FAQ
68
        }
69
        }
69
    ) or die Template->error();
70
    ) or die Template->error();
70
    my $self = {
71
    my $self = {
Lines 109-165 sub output { Link Here
109
    $vars->{opacstylesheet} = C4::Context->preference('opacstylesheet');
110
    $vars->{opacstylesheet} = C4::Context->preference('opacstylesheet');
110
111
111
    # add variables set via param to $vars for processing
112
    # add variables set via param to $vars for processing
112
    # and clean any utf8 mess
113
    for my $k ( keys %{ $self->{VARS} } ) {
113
    for my $k ( keys %{ $self->{VARS} } ) {
114
        $vars->{$k} = $self->{VARS}->{$k};
114
        $vars->{$k} = $self->{VARS}->{$k};
115
        if (ref($vars->{$k}) eq 'ARRAY'){
116
            utf8_arrayref($vars->{$k});
117
        }
118
        elsif (ref($vars->{$k}) eq 'HASH'){
119
            utf8_hashref($vars->{$k});
120
        }
121
        else {
122
            utf8::encode($vars->{$k}) if utf8::is_utf8($vars->{$k});
123
        }
124
    }
115
    }
125
    my $data;
116
    my $data;
126
#    binmode( STDOUT, ":utf8" );
127
    $template->process( $self->filename, $vars, \$data )
117
    $template->process( $self->filename, $vars, \$data )
128
      || die "Template process failed: ", $template->error();
118
      || die "Template process failed: ", $template->error();
129
    return $data;
119
    return $data;
130
}
120
}
131
121
132
sub utf8_arrayref {
122
133
    my $arrayref = shift;
134
    foreach my $element (@$arrayref){
135
        if (ref($element) eq 'ARRAY'){
136
            utf8_arrayref($element);
137
            next;
138
        }
139
        if (ref($element) eq 'HASH'){
140
            utf8_hashref($element);
141
            next;
142
        }
143
        utf8::encode($element) if utf8::is_utf8($element);
144
    }        
145
}         
146
147
sub utf8_hashref {
148
    my $hashref = shift;
149
    for my $key (keys %{$hashref}){
150
        if (ref($hashref->{$key}) eq 'ARRAY'){
151
            utf8_arrayref($hashref->{$key});
152
            next;
153
        }
154
        if (ref($hashref->{$key}) eq 'HASH'){
155
            utf8_hashref($hashref->{$key});
156
            next;
157
        }
158
        utf8::encode($hashref->{$key}) if utf8::is_utf8($hashref->{$key});
159
    }
160
}
161
        
162
        
163
# FIXME - this is a horrible hack to cache
123
# FIXME - this is a horrible hack to cache
164
# the current known-good language, temporarily
124
# the current known-good language, temporarily
165
# put in place to resolve bug 4403.  It is
125
# put in place to resolve bug 4403.  It is
(-)a/C4/XSLT.pm (+1 lines)
Lines 220-225 sub XSLTParse4Display { Link Here
220
    }
220
    }
221
    my $results      = $stylesheet->{$xslfilename}->transform($source);
221
    my $results      = $stylesheet->{$xslfilename}->transform($source);
222
    my $newxmlrecord = $stylesheet->{$xslfilename}->output_string($results);
222
    my $newxmlrecord = $stylesheet->{$xslfilename}->output_string($results);
223
    utf8::decode( $newxmlrecord );
223
    return $newxmlrecord;
224
    return $newxmlrecord;
224
}
225
}
225
226
(-)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/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/z3950_search.pl (-1 / +1 lines)
Lines 20-26 Link Here
20
20
21
use strict;
21
use strict;
22
#use warnings; FIXME - Bug 2505
22
#use warnings; FIXME - Bug 2505
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 / +1 lines)
Lines 46-52 use Business::ISBN; Link Here
46
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
46
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
47
# create a new CGI object
47
# create a new CGI object
48
# FIXME: no_undef_params needs to be tested
48
# FIXME: no_undef_params needs to be tested
49
use CGI qw('-no_undef_params');
49
use CGI qw( -no_undef_params -utf8 );
50
my $cgi = new CGI;
50
my $cgi = new CGI;
51
51
52
BEGIN {
52
BEGIN {
53
- 

Return to bug 6554