/[suikacvs]/messaging/manakai/lib/Message/Tool.pm
Suika

Contents of /messaging/manakai/lib/Message/Tool.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Sun Jul 28 00:31:38 2002 UTC (22 years, 4 months ago) by wakaba
Branch: MAIN
CVS Tags: before-dis2-200411, manakai-release-0-3-2, manakai-release-0-3-1, manakai-release-0-4-0, manakai-200612, msg-0-1, HEAD
Branch point for: branch-suikawiki-1, experimental-xml-parser-200401, stable
Changes since 1.1: +23 -2 lines
2002-07-28  Wakaba <w@suika.fam.cx>

	* Entity.pm (destination, sender): New methods.

1
2 =head1 NAME
3
4 Message::Tool -- Tools used with Message::* Perl Modules
5
6 =head1 DESCRIPTION
7
8 Useful functions that are intended to be used with Message::* Perl Modules.
9
10 Note that there is Message::Util, very similar named module,
11 but its functions are used by Message::* Perl Modules internally.
12
13 =cut
14
15 package Message::Tool;
16 use strict;
17 use vars qw($VERSION);
18 $VERSION=do{my @r=(q$Revision: 1.1 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
19
20 sub mail_downgrade ($%) {
21 my $msg = shift;
22 my %option = @_;
23 my $hdr = $msg->header;
24 ## "<" in display-name of From: field
25 my $from = $hdr->field ('from', -new_item_unless_exist => 0);
26 ## BUG: Non-ASCII 0x3A such as in JIS X 0208 are not supported.
27 if (ref $from && $from->item (0, -by => 'index')->display_name =~ /</) {
28 my $buggy = 0;
29 my @to = @{ $option{destination} };
30 ## TODO: Support Resent-* fields
31 @to = ($hdr->field ('to')->addr_spec,
32 $hdr->field ('cc')->addr_spec,
33 $hdr->field ('bcc')->addr_spec) unless @to > 0;
34 for (@to) {
35 $buggy = 1 if /\@jp-[a-z]\.ne\.jp$/i;
36 }
37 $from->item (0, -by => 'index')->option (output_display_name => 0) if $buggy;
38 }
39 }
40
41 sub escape_from ($;%) {
42 my $s = shift;
43 my %option = @_;
44 $option{-escape_first_line} = 1 unless defined $option{-escape_first_line};
45 $s =~ s/^(>*From\x20)/>$1/gm;
46 unless ($option{-escape_first_line}) {
47 $s =~ s/^>(>*From\x20)/$1/;
48 }
49 $s;
50 }
51 sub unescape_from ($;%) {
52 my $s = shift;
53 my %option = @_;
54 $option{-escape_first_line} = 1 unless defined $option{-escape_first_line};
55 $s =~ s/^>(>*From\x20)/$1/gm;
56 unless ($option{-escape_first_line}) {
57 $s =~ s/^(>*From\x20)/>$1/;
58 }
59 $s;
60 }
61
62 =head1 LICENSE
63
64 Copyright 2002 wakaba E<lt>w@suika.fam.cxE<gt>.
65
66 This program is free software; you can redistribute it and/or modify
67 it under the terms of the GNU General Public License as published by
68 the Free Software Foundation; either version 2 of the License, or
69 (at your option) any later version.
70
71 This program is distributed in the hope that it will be useful,
72 but WITHOUT ANY WARRANTY; without even the implied warranty of
73 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74 GNU General Public License for more details.
75
76 You should have received a copy of the GNU General Public License
77 along with this program; see the file COPYING. If not, write to
78 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
79 Boston, MA 02111-1307, USA.
80
81 =head1 CHANGE
82
83 See F<ChangeLog>.
84 $Date: 2002/07/26 12:42:00 $
85
86 =cut
87
88 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24