Lines 117-126
sub output {
Link Here
|
117 |
# and clean any utf8 mess |
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'){ |
120 |
my $rt = ref($vars->{$k}); |
|
|
121 |
if ($rt eq 'ARRAY') { |
121 |
utf8_arrayref($vars->{$k}); |
122 |
utf8_arrayref($vars->{$k}); |
122 |
} |
123 |
} |
123 |
elsif (ref($vars->{$k}) eq 'HASH'){ |
124 |
elsif ($rt eq 'HASH' || _utf8_is_whitelisted_object($rt)) { |
124 |
utf8_hashref($vars->{$k}); |
125 |
utf8_hashref($vars->{$k}); |
125 |
} |
126 |
} |
126 |
else { |
127 |
else { |
Lines 137-147
sub output {
Link Here
|
137 |
sub utf8_arrayref { |
138 |
sub utf8_arrayref { |
138 |
my $arrayref = shift; |
139 |
my $arrayref = shift; |
139 |
foreach my $element (@$arrayref){ |
140 |
foreach my $element (@$arrayref){ |
140 |
if (ref($element) eq 'ARRAY'){ |
141 |
my $rt = ref($element); |
|
|
142 |
if ($rt eq 'ARRAY'){ |
141 |
utf8_arrayref($element); |
143 |
utf8_arrayref($element); |
142 |
next; |
144 |
next; |
143 |
} |
145 |
} |
144 |
if (ref($element) eq 'HASH'){ |
146 |
if ($rt eq 'HASH' || _utf8_is_whitelisted_object($rt)) { |
145 |
utf8_hashref($element); |
147 |
utf8_hashref($element); |
146 |
next; |
148 |
next; |
147 |
} |
149 |
} |
Lines 152-170
sub utf8_arrayref {
Link Here
|
152 |
sub utf8_hashref { |
154 |
sub utf8_hashref { |
153 |
my $hashref = shift; |
155 |
my $hashref = shift; |
154 |
for my $key (keys %{$hashref}){ |
156 |
for my $key (keys %{$hashref}){ |
155 |
if (ref($hashref->{$key}) eq 'ARRAY'){ |
157 |
my $rt = ref($hashref->{$key}); |
|
|
158 |
if ($rt eq 'ARRAY'){ |
156 |
utf8_arrayref($hashref->{$key}); |
159 |
utf8_arrayref($hashref->{$key}); |
157 |
next; |
160 |
next; |
158 |
} |
161 |
} |
159 |
if (ref($hashref->{$key}) eq 'HASH'){ |
162 |
if ($rt eq 'HASH' || _utf8_is_whitelisted_object($rt)) { |
160 |
utf8_hashref($hashref->{$key}); |
163 |
utf8_hashref($hashref->{$key}); |
161 |
next; |
164 |
next; |
162 |
} |
165 |
} |
163 |
utf8::encode($hashref->{$key}) if utf8::is_utf8($hashref->{$key}); |
166 |
utf8::encode($hashref->{$key}) if utf8::is_utf8($hashref->{$key}); |
164 |
} |
167 |
} |
165 |
} |
168 |
} |
166 |
|
169 |
|
167 |
|
170 |
sub _utf8_is_whitelisted_object { |
|
|
171 |
my $rt = shift; |
172 |
$rt eq '' && return(0); |
173 |
my @whitelist = qw( Koha::AdditionalField ); |
174 |
map { $_ eq $rt && return(1); } @whitelist; |
175 |
0; |
176 |
} |
177 |
|
168 |
# FIXME - this is a horrible hack to cache |
178 |
# FIXME - this is a horrible hack to cache |
169 |
# the current known-good language, temporarily |
179 |
# the current known-good language, temporarily |
170 |
# put in place to resolve bug 4403. It is |
180 |
# put in place to resolve bug 4403. It is |
171 |
- |
|
|