Bugzilla – Attachment 12986 Details for
Bug 8872
Improve encoding for xslt files, showmarc and opac-showmarc
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8872 Encoding issues in Templates.pm
Bug-8872-Encoding-issues-in-Templatespm.patch (text/plain), 3.29 KB, created by
Jared Camins-Esakov
on 2012-10-21 15:30:34 UTC
(
hide
)
Description:
Bug 8872 Encoding issues in Templates.pm
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2012-10-21 15:30:34 UTC
Size:
3.29 KB
patch
obsolete
>From 74b1933e66642755974629c0f5db623232b0b627 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 4 Oct 2012 12:24:45 +0200 >Subject: [PATCH] Bug 8872 Encoding issues in Templates.pm > >Adds specific encoding parameter when creating Template object. >Note that the instruction binmode => ':utf8' could have been added also >to the process method. But since it outputs to a Perl variable, this is >not needed. >Finally, instead of the old encoding of all parameters before processing, >the output of process is encoded to UTF-8 octets. Note that Perl could >have handled this internally, but this would require adding a use open >statement, setting IO layers to UTF-8 in all scripts. > >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >--- > C4/Templates.pm | 45 ++------------------------------------------- > 1 file changed, 2 insertions(+), 43 deletions(-) > >diff --git a/C4/Templates.pm b/C4/Templates.pm >index 507e077..37bf13d 100644 >--- a/C4/Templates.pm >+++ b/C4/Templates.pm >@@ -67,6 +67,7 @@ sub new { > COMPILE_DIR => C4::Context->config('template_cache_dir')?C4::Context->config('template_cache_dir'):'',, > INCLUDE_PATH => \@includes, > FILTERS => {}, >+ ENCODING => 'utf8', > } > ) or die Template->error(); > my $self = { >@@ -90,7 +91,6 @@ sub output { > my $self = shift; > my $vars = shift; > >-# my $file = $self->htdocs . '/' . $self->theme .'/'.$self->lang.'/'.$self->filename; > my $template = $self->{TEMPLATE}; > if ( $self->interface eq 'intranet' ) { > $vars->{themelang} = '/intranet-tmpl'; >@@ -114,56 +114,15 @@ sub output { > C4::Context->preference('opaclayoutstylesheet'); > > # add variables set via param to $vars for processing >- # and clean any utf8 mess > for my $k ( keys %{ $self->{VARS} } ) { > $vars->{$k} = $self->{VARS}->{$k}; >- if (ref($vars->{$k}) eq 'ARRAY'){ >- utf8_arrayref($vars->{$k}); >- } >- elsif (ref($vars->{$k}) eq 'HASH'){ >- utf8_hashref($vars->{$k}); >- } >- else { >- utf8::encode($vars->{$k}) if utf8::is_utf8($vars->{$k}); >- } > } > my $data; >-# binmode( STDOUT, ":utf8" ); > $template->process( $self->filename, $vars, \$data ) > || die "Template process failed: ", $template->error(); >+ utf8::encode($data) if utf8::is_utf8($data); > return $data; > } >- >-sub utf8_arrayref { >- my $arrayref = shift; >- foreach my $element (@$arrayref){ >- if (ref($element) eq 'ARRAY'){ >- utf8_arrayref($element); >- next; >- } >- if (ref($element) eq 'HASH'){ >- utf8_hashref($element); >- next; >- } >- utf8::encode($element) if utf8::is_utf8($element); >- } >-} >- >-sub utf8_hashref { >- my $hashref = shift; >- for my $key (keys %{$hashref}){ >- if (ref($hashref->{$key}) eq 'ARRAY'){ >- utf8_arrayref($hashref->{$key}); >- next; >- } >- if (ref($hashref->{$key}) eq 'HASH'){ >- utf8_hashref($hashref->{$key}); >- next; >- } >- utf8::encode($hashref->{$key}) if utf8::is_utf8($hashref->{$key}); >- } >-} >- > > # FIXME - this is a horrible hack to cache > # the current known-good language, temporarily >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8872
:
12755
|
12756
|
12757
|
12758
|
12759
|
12986
|
12987
|
12988
|
12989
|
12990
|
13171
|
13172
|
13173
|
13244
|
13245
|
13248