blob: 3ccf5179f828af09b9766975e4682ebaa0f05e67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
#-*- perl -*-
#
# Copyright (C) 2001 Ken'ichi Fukamachi
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
# $Id$
# $FML$
#
### ###
### CAUTION: THE CHARSET OF THIS FILE IS "EUC-JAPAN". ###
### ###
package Dialect::Japanese::Subject;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK);
use Carp;
use Jcode;
=head1 NAME
Dialect::Japanese::Subject - Japanese specific handling of a subject
=head1 SYNOPSIS
use Dialect::Japanese::Subject;
$is_reply = Dialect::Japanese::Subject::is_reply($subject);
=head1 DESCRIPTION
a collection to handle Japanese specific representations which appears
in the subject.
=cut
require Exporter;
@ISA = qw(Exporter);
# XXX we should it in proper way in the future.
# XXX but we import it anyway for further rewriting.
my $CUT_OFF_RERERE_PATTERN = '';
my $CUT_OFF_RERERE_HOOK = '';
# subjec reply pattern
# apply patch from OGAWA Kunihiko <kuni@edit.ne.jp>
# fml-support:7626 7653 07666
# Re: Re2: Re[2]: Re(2): Re^2: Re*2:
my $pattern = 'Re:|Re\d+:|Re\[\d+\]:|Re\(\d+\):|Re\^\d+:|Re\*\d+:';
$pattern .= '|(�ֿ�|��|�ң�|�ң�)(\s*:|��)';
=head1 METHODS
=head2 C<new()>
usual constructor.
=head2 C<is_reply($string)>
check whether C<$string> looks like a reply message.
C<$string> is a C<Subject:> of the mail header.
For example, it is like this:
Re: reply to your messages
=cut
sub new
{
my ($self) = @_;
my ($type) = ref($self) || $self;
my $me = {};
return bless $me, $type;
}
sub is_reply
{
my ($self, $x) = @_;
return 0 unless $x;
&Jcode::convert(\$x, 'euc');
return ($x =~ /^((\s|(��))*($pattern)\s*)+/ ? 1 : 0);
}
=head2 C<cut_off_reply_tag($subject)>
cut off C<Re:> in the string C<$subject> like C<Re: ... >
within C<Subject:>.
=cut
# fml-support: 07507
# sub CutOffRe
# {
# ���ޤޤǤɤ���� Re: �Ȥ��ȤäѤ餦
#
# if ($LANGUAGE eq 'Japanese') {
# ���ܸ������¸�饤�֥�������
# ������� $CUT_OFF_PATTERN (config.ph)�ʤɤˤ������ä�
# �ڤ���Ȥ��Τ��ɤ��ʤ��ä����ܸ��������Ȥ��⤦�櫓��
# �ǡ����Υ饤�֥�����Ǽ¹Ԥ����
# }
#
# run-hooks $CUT_OFF_HOOK(�桼�����HOOK)
#}
# �����к�
sub cut_off_reply_tag
{
my ($subject) = @_;
my ($y, $limit);
Jcode::convert(\$subject, 'euc');
if ($CUT_OFF_RERERE_PATTERN) {
Jcode::convert(\$CUT_OFF_RERERE_PATTERN, 'euc');
}
$pattern .= '|' . $CUT_OFF_RERERE_PATTERN if ($CUT_OFF_RERERE_PATTERN);
# fixed by OGAWA Kunihiko <kuni@edit.ne.jp> (fml-support: 07815)
# $subject =~ s/^((\s*|(��)*)*($pattern)\s*)+/Re: /oi;
$subject =~ s/^((\s|(��))*($pattern)\s*)+/Re: /oi;
if ($CUT_OFF_RERERE_HOOK) {
eval($CUT_OFF_RERERE_HOOK);
&Log($@) if $@;
}
Jcode::convert(\$subject, 'jis');
$subject;
}
=head1 AUTHOR
Ken'ichi Fukamachi
=head1 COPYRIGHT
Copyright (C) 2001 Ken'ichi Fukamachi
All rights reserved. This program is free software; you can
redistribute it and/or modify it under the same terms as Perl itself.
=head1 HISTORY
Dialect::Japanese::Subject appeared in fml5 mailing list driver package.
See C<http://www.fml.org/> for more details.
=cut
1;
|