Skip to content

Commit a15d4f6

Browse files
author
Comment
committed
Item13378: more file opens requiring utf8 layer
1 parent c79f20c commit a15d4f6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

core/lib/Foswiki/PageCache/DBI.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ HERE
187187
$this->{cacheDir} . '/' . $variation->{md5} );
188188

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

@@ -225,7 +226,7 @@ HERE
225226
if ( defined $variation ) {
226227
my $FILE;
227228
my $fileName = $this->{cacheDir} . '/' . $variation->{md5};
228-
open( $FILE, '<', $fileName ) or return;
229+
open( $FILE, '<:encoding(utf-8)', $fileName ) or return;
229230
local $/ = undef;
230231
$variation->{data} = <$FILE>;
231232
close($FILE);

core/lib/Foswiki/Templates.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ sub _readFile {
586586
my ( $session, $fn ) = @_;
587587
my $F;
588588

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

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

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

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

0 commit comments

Comments
 (0)