force_charset is now global

This commit is contained in:
Jamie Cameron
2009-03-26 05:26:02 +00:00
parent c3a6135236
commit c2e9a956e9
5 changed files with 35 additions and 5 deletions

View File

@@ -11,7 +11,6 @@ use WebminCore;
@cats = &get_visible_modules_categories();
@modules = map { @{$_->{'modules'}} } @cats;
$charset = defined($force_charset) ? $force_charset : &get_charset();
print &popup_header();
print <<EOF;
<link rel="stylesheet" type="text/css" href="left.css" />

View File

@@ -3512,5 +3512,34 @@ close(OUTr);
return @errs;
}
# get_mail_charset(&mail, &body)
# Returns the character set to use for the HTML page for some email
sub get_mail_charset
{
my ($mail, $body) = @_;
my $ctype;
if ($body) {
$ctype = $body->{'header'}->{'content-type'};
}
$ctype ||= $mail->{'header'}->{'content-type'};
if ($ctype =~ /charset="([a-z0-9\-]+)"/i ||
$ctype =~ /charset='([a-z0-9\-]+)'/i ||
$ctype =~ /charset=([a-z0-9\-]+)/i) {
$charset = $1;
}
}
## Special handling of HTML header charset ($force_charset):
## For japanese text(ISO-2022-JP/EUC=JP/SJIS), the HTML output and
## text contents ($bodycontents) are already converted to EUC,
## so overriding HTML charset to that in the mail header ($charset)
## is generally wrong. (cf. mailbox/boxes-lib.pl:eucconv())
if ( &get_charset() =~ /^EUC/i ) { # EUC-JP,EUC-KR
return undef;
}
else {
return $charset;
}
}
1;

View File

@@ -3,7 +3,7 @@
# View a single email message
require './mailboxes-lib.pl';
$force_charset = '';
$main::force_charset = '';
&ReadParse();
&can_user($in{'user'}) || &error($text{'mail_ecannot'});
if (&is_user($in{'user'})) {

View File

@@ -11,7 +11,7 @@ else {
require './view-lib.pl';
if ($config{'charset'}) {
$force_charset = $config{'charset'};
$main::force_charset = $config{'charset'};
}
if ($ENV{'CONTENT_TYPE'} !~ /boundary=/) {
&ReadParse();

View File

@@ -754,7 +754,8 @@ sub header
{
return if ($main::done_webmin_header++);
my $ll;
my $charset = defined($force_charset) ? $force_charset : &get_charset();
my $charset = defined($main::force_charset) ? $main::force_charset
: &get_charset();
&PrintHeader($charset);
&load_theme_library();
if (defined(&theme_header)) {
@@ -1019,7 +1020,8 @@ sub popup_header
{
return if ($main::done_webmin_header++);
my $ll;
my $charset = defined($force_charset) ? $force_charset : &get_charset();
my $charset = defined($main::force_charset) ? $main::force_charset
: &get_charset();
&PrintHeader($charset);
&load_theme_library();
if (defined(&theme_popup_header)) {