From ab465a6f91ad38858c33fddd30a639d0b4bcf4d8 Mon Sep 17 00:00:00 2001 From: Fumiaki Yoshimatsu Date: Thu, 10 Sep 2009 06:02:07 +0000 Subject: [PATCH] HTTP headers should be written by ourselves under perlis.dll. BugId:102298 --- mt-check.cgi | 79 +++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/mt-check.cgi b/mt-check.cgi index b916c43181..3b9e99889a 100755 --- a/mt-check.cgi +++ b/mt-check.cgi @@ -80,7 +80,7 @@ eval { sub trans_templ { my($text) = @_; - return Encode::encode( $mt->config->PublishCharset, $mt->translate_templatized($text) ) if $mt; + return $mt->translate_templatized($text) if $mt; $text =~ s!(]+?>|[^\3]+?)+?\3))+?\s*/?>)! my($msg, %args) = ($1); #print $msg; @@ -95,7 +95,7 @@ sub trans_templ { $translation =~ s/([\\'])/\\$1/sg if $args{escape}; $translation; !ge; - Encode::encode_utf8( $text ); + return $text; } sub translate { @@ -129,9 +129,23 @@ sub merge_params { $msg; } -print "Content-Type: text/html; charset=utf-8\n\n"; +sub print_encode { + my ( $text ) = @_; + if ( $mt ) { + print Encode::encode( $mt->config->PublishCharset, $text ); + } + else { + print Encode::encode_utf8( $text ); + } +} + +if ( exists( $ENV{PERLXS} ) && ( $ENV{PERLXS} eq 'PerlIS' ) ) { + print_encode( "HTTP/1.0 200 OK\n" ); + print_encode( "Connection: close\n" ); +} +print_encode( "Content-Type: text/html; charset=utf-8\r\n\r\n" ); if (!$view) { - print trans_templ(< @@ -251,11 +265,11 @@ if (!$view) { HTML if ($mt_static_path) { - print "\n"; + print_encode( "\n" ); } else { - print "\n"; + print_encode( "\n" ); } - print trans_templ(<

<__trans phrase="Movable Type System Check"> [mt-check.cgi]

@@ -369,7 +383,7 @@ CONFIG } my $server = $ENV{SERVER_SOFTWARE}; my $inc_path = join "
\n", @INC; -print trans_templ(<<__trans phrase="System Information"> $perl_ver_check $config_check @@ -377,13 +391,13 @@ INFO if ($version) { # sanitize down to letters numbers dashes and period $version =~ s/[^a-zA-Z0-9\-\.]//g; -print trans_templ(<
  • <__trans phrase="Movable Type version:"> $version
  • INFO } -print trans_templ(<
  • <__trans phrase="Current working directory:"> $cwd
  • <__trans phrase="MT home directory:"> $ENV{MT_HOME}
  • @@ -392,7 +406,7 @@ print trans_templ(<<__trans phrase="Perl include path:">
    $inc_path INFO if ($server) { -print trans_templ(<<__trans phrase="Web server:"> $server INFO } @@ -405,10 +419,10 @@ local *FH; if (open(FH, ">$TMP")) { close FH; unlink($TMP); - print trans_templ('
  • <__trans phrase="(Probably) Running under cgiwrap or suexec">
  • ' . "\n"); + print_encode( trans_templ('
  • <__trans phrase="(Probably) Running under cgiwrap or suexec">
  • ' . "\n") ); } -print "\n\n\n"; +print_encode( "\n\n\n" ); exit if $ENV{QUERY_STRING} && $ENV{QUERY_STRING} eq 'sys-check'; @@ -460,10 +474,10 @@ for my $list (\@REQ, \@DATA, \@OPT) { } else { $type = translate("Optional"); } - print trans_templ(qq{

    <__trans phrase="[_1] [_2] Modules" params="$phrase%%$type">

    \n\t
    \n}); + print_encode( trans_templ(qq{

    <__trans phrase="[_1] [_2] Modules" params="$phrase%%$type">

    \n\t
    \n}) ); if (!$req && !$data) { if (!$view) { - print trans_templ(<<__trans phrase="The following modules are optional. If your server does not have these modules installed, you only need to install them if you require the functionality that the module provides.">

    MSG @@ -471,7 +485,7 @@ MSG } if ($data) { if (!$view) { - print trans_templ(<<__trans phrase="Some of the following modules are required by the various data storage options in Movable Type. In order run the system, your server needs to have DBI and at least one of the other modules installed.">

    MSG @@ -484,49 +498,44 @@ MSG if ('CODE' eq ref($desc)) { $desc = $desc->(); } - print "
    \n" if $mod =~ m/^DBD::/; - print "

    $mod" . - ($ver ? " (version >= $ver)" : "") . "

    "; + print_encode( "
    \n" ) if $mod =~ m/^DBD::/; + print_encode( "

    $mod" . + ($ver ? " (version >= $ver)" : "") . "

    " ); eval("use $mod" . ($ver ? " $ver;" : ";")); if ($@) { $is_good = 0 if $req; my $msg = $ver ? trans_templ(qq{

    <__trans phrase="Either your server does not have [_1] installed, the version that is installed is too old, or [_1] requires another module that is not installed." params="$mod"> }) : trans_templ(qq{

    <__trans phrase="Your server does not have [_1] installed, or [_1] requires another module that is not installed." params="$mod"> }); - if ( $mt ) { - print Encode::encode( $mt->config->PublishCharset, $desc ); - } - else { - print Encode::encode_utf8( $desc ); - } - print trans_templ(qq{ <__trans phrase="Please consult the installation instructions for help in installing [_1]." params="$mod">

    \n\n}); - print $msg; - print "\n\n"; + print_encode( $desc ); + print_encode( trans_templ(qq{ <__trans phrase="Please consult the installation instructions for help in installing [_1]." params="$mod">

    \n\n}) ); + print_encode( $msg ); + print_encode( "\n\n" ); } else { if ($data) { $dbi_is_okay = 1 if $mod eq 'DBI'; if ($mod eq 'DBD::mysql') { if ($DBD::mysql::VERSION == 3.0000) { - print trans_templ(qq{

    <__trans phrase="The DBD::mysql version you have installed is known to be incompatible with Movable Type. Please install the current release available from CPAN.">

    }); + print_encode( trans_templ(qq{

    <__trans phrase="The DBD::mysql version you have installed is known to be incompatible with Movable Type. Please install the current release available from CPAN.">

    }) ); } } if (!$dbi_is_okay) { - print trans_templ(qq{

    <__trans phrase="The $mod is installed properly, but requires an updated DBI module. Please see note above regarding the DBI module requirements.">

    }); + print_encode( trans_templ(qq{

    <__trans phrase="The $mod is installed properly, but requires an updated DBI module. Please see note above regarding the DBI module requirements.">

    }) ); } else { $got_one_data = 1 if $mod ne 'DBI'; } } - print trans_templ(qq{

    <__trans phrase="Your server has [_1] installed (version [_2])." params="$mod%%} . $mod->VERSION . qq{">

    \n\n}); + print_encode( trans_templ(qq{

    <__trans phrase="Your server has [_1] installed (version [_2])." params="$mod%%} . $mod->VERSION . qq{">

    \n\n}) ); } - print "
    \n" if $mod =~ m/^DBD::/; + print_encode( "
    \n" ) if $mod =~ m/^DBD::/; } $is_good &= $got_one_data if $data; - print "\n\t
    \n\n"; + print_encode( "\n\t
    \n\n" ); } if ($is_good && $cfg_exist) { if (!$view) { - print trans_templ(<

    <__trans phrase="Movable Type System Check Successful">

    <__trans phrase="You're ready to go!"> <__trans phrase="Your server has all of the required modules installed; you do not need to perform any additional module installations. Continue with the installation instructions.">

    @@ -538,4 +547,4 @@ HTML } } -print "\n\n\n"; +print_encode( "\n\n\n" );