Subject: | CGI::SSI breaks when STDOUT is configured for utf8 using "binmode(STDOUT, ":utf8");" |
Date: | Wed, 19 Apr 2017 16:05:06 -0700 |
To: | bug-CGI-SSI [...] rt.cpan.org |
From: | Tristan Savatier <tristan [...] bok.net> |
hi,
CGI::SSI breaks when STDOUT is configured for utf8 using
"binmode(STDOUT, ":utf8");"
test case:
=============================================================
use CGI::SSI;
$ssi = CGI::SSI->new();
$ssi = tie(*STDOUT, 'CGI::SSI', filehandle => 'STDOUT');
$ssi->set(varname => 1);
binmode(STDOUT, ":utf8");
print '<!--#if expr="$varname" -->ok<!--#else -->nope<!--#endif -->' . "\n";
print '<!--#if expr="$varname2" -->ok<!--#else -->nope<!--#endif -->' . "\n";
=============================================================
this produces the error:
Failed to copy the filehandle (main::STDOUT): Bad file descriptor at
/usr/local/share/perl5/CGI/SSI.pm line 81.
if you comment-out the "binmode" line, the test works fine and prints
ok
nope
versions:
CGI:SSI 0.92
perl v5.10.1 (*) built for x86_64-linux-thread-multi
Linux 2.6.32-042stab120.5 #1 SMP Tue Oct 25 22:31:12 MSK 2016 x86_64
x86_64 x86_64 GNU/Linux
-t