Skip to content

Commit

Permalink
Item13378: more file opens requiring utf8 layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Comment committed May 19, 2015
1 parent c79f20c commit a15d4f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions core/lib/Foswiki/PageCache/DBI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ HERE
$this->{cacheDir} . '/' . $variation->{md5} );

#writeDebug("saving data of $webTopic into $fileName");
open( $FILE, '>', $fileName ) or die "Can't create file $fileName - $!\n";
open( $FILE, '>:encoding(utf-8)', $fileName )
or die "Can't create file $fileName - $!\n";
print $FILE $variation->{data};
close($FILE);

Expand Down Expand Up @@ -225,7 +226,7 @@ HERE
if ( defined $variation ) {
my $FILE;
my $fileName = $this->{cacheDir} . '/' . $variation->{md5};
open( $FILE, '<', $fileName ) or return;
open( $FILE, '<:encoding(utf-8)', $fileName ) or return;
local $/ = undef;
$variation->{data} = <$FILE>;
close($FILE);
Expand Down
6 changes: 3 additions & 3 deletions core/lib/Foswiki/Templates.pm
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ sub _readFile {
my ( $session, $fn ) = @_;
my $F;

if ( open( $F, '<', $fn ) ) {
if ( open( $F, '<:encoding(utf-8)', $fn ) ) {
local $/;
my $text = <$F>;
close($F);
Expand Down Expand Up @@ -624,7 +624,7 @@ sub saveTemplateToCache {
my $filename = Foswiki::Sandbox::untaintUnchecked(
$tmpl_cachedir . '/' . $name . '__' . $skins . '__' . $web . '.tmpl' );

open( my $file, '>', $filename ) or do {
open( my $file, '>:encoding(utf-8)', $filename ) or do {
die "Can't create file $filename - $!\n" if DEBUG;
print STDERR "Can't create file $filename - $!\n";

Expand All @@ -646,7 +646,7 @@ sub getTemplateFromCache {
$tmpl_cachedir . '/' . $name . '__' . $skins . '__' . $web . '.tmpl' );

if ( -e $filename ) {
open( my $in_file, '<', $filename ) or return;
open( my $in_file, '<:encoding(utf-8)', $filename ) or return;
local $/ = undef; # set to read to EOF
my $data = <$in_file>;
close($in_file);
Expand Down

0 comments on commit a15d4f6

Please sign in to comment.