summaryrefslogtreecommitdiff
path: root/fml/lib/FML/Process
diff options
context:
space:
mode:
authorfukachan <fukachan>2004-02-26 08:05:37 +0000
committerfukachan <fukachan>2004-02-26 08:05:37 +0000
commit4ffe02f1096fb43a47ecd3243238b12650ab1dca (patch)
tree2d0c24eda31737e051eebbeff6f086a47376d1ab /fml/lib/FML/Process
parent5a319f23bc0e01ddd9a6b7821302e4a3d1835bc4 (diff)
downloadfml8-4ffe02f1096fb43a47ecd3243238b12650ab1dca.tar.gz
fml8-4ffe02f1096fb43a47ecd3243238b12650ab1dca.tar.bz2
fml8-4ffe02f1096fb43a47ecd3243238b12650ab1dca.zip
more proper charset handling based on Content-Type: field.
Diffstat (limited to 'fml/lib/FML/Process')
-rw-r--r--fml/lib/FML/Process/Kernel.pm46
1 files changed, 41 insertions, 5 deletions
diff --git a/fml/lib/FML/Process/Kernel.pm b/fml/lib/FML/Process/Kernel.pm
index b144ad7e..1d3e0ecf 100644
--- a/fml/lib/FML/Process/Kernel.pm
+++ b/fml/lib/FML/Process/Kernel.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Kernel.pm,v 1.207 2004/02/15 09:34:41 fukachan Exp $
+# $FML: Kernel.pm,v 1.208 2004/02/26 05:07:57 fukachan Exp $
#
package FML::Process::Kernel;
@@ -1012,11 +1012,47 @@ sub parse_incoming_message
}
}
- # Accept-Language: handling
+ # use Content-Type: and Accept-Language: as hints.
if (defined $msg) {
- my $list = $msg->accept_language_list();
+ $curproc->_inject_charset_hints($msg);
+ }
+}
+
+
+# Descriptions: inject charset hints picked up from message header.
+# Arguments: OBJ($curproc) OBJ($msg)
+# Side Effects: update corresponding PCB fields.
+# Return Value: none
+sub _inject_charset_hints
+{
+ my ($curproc, $msg) = @_;
+ my $charset = $msg->charset() || '';
+ my $list = $msg->accept_language_list() || [];
+ my $liststr = join("", @$list);
+
+ $curproc->log("hints: charset=\"$charset\" accept_language=[$liststr]");
+
+ # 1. prefer Accept-Language: alyways, ignore Content-Type: in this case.
+ if ($list) {
+ $curproc->log("hints: save accept_language=[@$list]");
$curproc->set_accept_language_list($list);
}
+
+ # 2. analyze Content-Type: if valid Accept-Languge: unspecified.
+ if ($liststr eq '*' && $charset) {
+ # validate charset usage.
+ # iso-2022-jp -> japanese -> iso-2022-jp
+ # sjis -> japanese -> iso-2022-jp
+ # euc-jp -> japanese -> iso-2022-jp
+ use Mail::Message::Charset;
+ my $char = new Mail::Message::Charset;
+ my $lang = $char->message_charset_to_language($charset);
+ $charset = $char->language_to_message_charset($lang);
+
+ $curproc->log("hints: use \"$charset\" as message charset");
+ $curproc->set_charset('message', $charset);
+ $curproc->set_charset('reply_message', $charset);
+ }
}
@@ -1688,8 +1724,8 @@ This $args is passed through to reply_message().
sub reply_message_nl
{
my ($curproc, $class, $default_msg, $rm_args) = @_;
- my $config = $curproc->config();
- my $buf = $curproc->message_nl($class, $default_msg, $rm_args);
+ my $config = $curproc->config();
+ my $buf = $curproc->message_nl($class, $default_msg, $rm_args);
$curproc->caller_info($class, caller) if $debug;