[Namazu-users-ja 736] mailnews.pl with --decode-base64
Hideyuki SHIRAI ( 白井秀行 )
shirai @ meadowy.org
2006年 4月 20日 (木) 18:01:54 JST
白井です。
遅ればせながら、Namazu 2.0.16 に乗り換えました。
そこで、mknmz に新たに導入された --decode-base64 オプションを試
しているのですが、ちょっと挙動に悩んだので、以下のメールを作って
実験しました。
(1) と (2) は最初の text/plain のパートに "日本語" と書いてあり、
"実験" と書いてあるファイルをそれぞれに示した ct & charset で 添
付してあります。
(3) と (4) は single パートのメールで、それぞれに示した ct &
charset で "実験" と書いてあります。
(1) App/Oct として base64 したパートを付ける
test.1 app/oct(euc-jp)
test.2 app/oct(iso-2022-jp)
test.3 app/oct(shift_jis)
test.4 app/oct(utf-8)
(2) text/plain として base64 したパートを付ける
test.11 text/plain(euc-jp)
test.12 text/plain(iso-2022-jp)
test.13 text/plain(shift_jis)
test.14 text/plain(utf-8)
(3) App/Oct(Base64) のみのメール
test.21 app/oct(euc-jp) only
test.22 app/oct(iso-2022-jp) only
test.23 app/oct(shift_jis) only
test.24 app/oct(utf-8) only
(4) Text/Plain(Base64) のみのメール
test.31 text/plain(euc-jp) only
test.32 text/plain(iso-2022-jp) only
test.33 text/plain(shift_jis) only
test.34 text/plain(utf-8) only
その結果、--decode-base64 をつけても (1) の四つと test.11 しか期
待どおりに検索しないことがわかりました。
実験方法は添付の test.tar.gz の中身にたいして、
% mknmz --decode-base64 /path-to/test
としたものです。(3) は検索出来なくてもよいと思うのですが、(2)、
(4) の形式は扱ってほしいので、添付のパッチを書いてみました。
試したかぎりでは (3) 以外は "実験" で全部検索でき、満足なのです
が、やっつけ仕事なので検討していただけるとうれしいです。
# (5) おまけ
# test.42 iso-2022-jp + iso-2022-jp(non B64)
--
白井秀行@ Perl って何年ぶりかしら ^^;;;
-------------- next part --------------
テキスト形式以外の添付ファイルを保管しました...
ファイル名: test.tar.gz
型: application/octet-stream
サイズ: 1694 バイト
説明: =?iso-2022-jp?B?GyRCJUYlOSVIJWEhPCVrGyhC?=
URL: http://www.namazu.org/pipermail/namazu-users-ja/attachments/20060420/a5acbd49/test.tar.obj
-------------- next part --------------
--- mailnews.pl.orig 2006-04-20 17:37:28.926269000 +0900
+++ mailnews.pl 2006-04-20 17:28:32.254063000 +0900
@@ -89,6 +89,9 @@
my $boundary = "";
my $line = "";
my $partial = 0;
+ my $base64 = 0;
+ my $qencode = 0;
+ my $textplain = 0;
$htmlmail = "";
@@ -123,6 +126,13 @@
my $weight = $conf::Weight{'html'}->{'title'};
$$weighted_str .= "\x7f$weight\x7f$line\x7f/$weight\x7f\n";
+ } elsif ($line =~ s/^content-transfer-encoding:\s*(\S+)$//i) {
+ my $cont_encode = $1;
+ if ($cont_encode =~ /base64/) {
+ $base64 = 1;
+ } elsif ($cont_encode =~ /quoted-printable/){
+ $qencode = 1;
+ }
} elsif ($line =~ s/^content-type:\s*//i) {
if ($line =~ /multipart.*boundary="(.*?)"/si ||
$line =~ /multipart.*boundary=(.*?)(?:\s|$)/mi) {
@@ -137,6 +147,8 @@
# The simplest form of an HTML email message.
util::dprint("text/html mail\n");
$htmlmail = "yes";
+ } elsif ($line =~ m!text/plain!i) {
+ $textplain = 1;
} elsif ($line !~ m!text/plain!i) {
$$contref = '';
return;
@@ -165,8 +177,16 @@
}
$$contref = join("\n", @tmp);
+ if ($textplain && $base64) {
+ base64_filter($contref);
+ codeconv::codeconv_document($contref);
+ }
+ elsif ($textplain && $qencode) {
+ quotedprint_filter($contref);
+ codeconv::codeconv_document($contref);
+ }
# Handle MIME multipart message.
- if ($boundary) {
+ elsif ($boundary) {
$boundary =~ s/(\W)/\\$1/g;
$$contref =~ s/This is multipart message.\n//i;
@@ -211,9 +231,7 @@
quotedprint_filter(\$body);
}
- if ($contenttype =~ m!text/plain!){
- $$contref .= $body;
- } elsif ($contenttype =~ m!multipart/alternative!){
+ if ($contenttype =~ m!multipart/alternative!){
if ($head =~ /boundary="(.*?)"/si ||
$head =~ /boundary=(.*?)(?:\s|$)/mi) {
my $boundary2 = $1;
@@ -222,6 +240,9 @@
multipart_process(\$body, $boundary2, $weighted_str, $fields);
$$contref .= $body;
}
+ } elsif ($body ne "" && $contenttype =~ m!text/plain!) {
+ codeconv::codeconv_document(\$body);
+ $$contref .= $body;
} elsif ($body ne "") {
nesting_filter(\$head, \$body, $contenttype, $weighted_str);
$$contref .= $body;
Namazu-users-ja メーリングリストの案内