diff options
| author | fukachan <fukachan> | 2001-02-18 11:40:10 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-02-18 11:40:10 +0000 |
| commit | c14948d39c96a77764babc5fe8e030d2e10bdca7 (patch) | |
| tree | ccf110f1d77b681d43a16a66b14590502179099f | |
| parent | 41e6eb1f2f94f9ae1e0e2ee0660375a9a40b2616 (diff) | |
| download | fml8-c14948d39c96a77764babc5fe8e030d2e10bdca7.tar.gz fml8-c14948d39c96a77764babc5fe8e030d2e10bdca7.tar.bz2 fml8-c14948d39c96a77764babc5fe8e030d2e10bdca7.zip | |
enable encode/decode for quoted-printable strings
| -rw-r--r-- | fml/lib/FML/MIME.pm | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/fml/lib/FML/MIME.pm b/fml/lib/FML/MIME.pm index 46d238e2..ab005792 100644 --- a/fml/lib/FML/MIME.pm +++ b/fml/lib/FML/MIME.pm @@ -25,18 +25,18 @@ sub decode_mime_string my $charset = $options->{ 'charset' } || 'euc-japan'; if ($charset eq 'euc-japan') { - use Jcode; use MIME::Base64; - if ($str =~ /=\?ISO\-2022\-JP\?B\?(\S+\=*)\?=/i) { $str =~ s/=\?ISO\-2022\-JP\?B\?(\S+\=*)\?=/decode_base64($1)/gie; } - if ($str =~ /=\?ISO\-2022\-JP\?B\?(\S+\=*)\?=/i) { - $str =~ s/=\?ISO\-2022\-JP\?B\?(\S+\=*)\?=/decode_base64($1)/gie; + use MIME::QuotedPrint; + if ($str =~ /=\?ISO\-2022\-JP\?Q\?(\S+\=*)\?=/i) { + $str =~ s/=\?ISO\-2022\-JP\?Q\?(\S+\=*)\?=/decode_qp($1)/gie; } } + use Jcode; &Jcode::convert(\$str, 'euc'); $str; } @@ -46,12 +46,25 @@ sub encode_mime_string { my ($str, $options) = @_; my $charset = $options->{ 'charset' } || 'iso-2022-jp'; + my $encode = $options->{ 'encode' } || 'base64'; + my $header = '=?'. $charset; + my $trailor = '?='; + use Jcode; &Jcode::convert(\$str, 'jis'); - $str = encode_base64($str); - $str =~ s/\n$//; - return '=?'. $charset . '?B?' . $str . '?='; + if ($encode eq 'base64') { + $header .= '?B?'; + $str = encode_base64($str); + } + elsif ($encode eq 'qp') { + $header .= '?Q?'; + $str = encode_qp($str); + $str =~ s/(\s)/${trailor}${1}${header}/g; + } + + $str =~ s/\n$//; + return ($header . $str . $trailor); } |
