/[suikacvs]/messaging/manakai/lib/Message/Header/RFC822.pm
Suika

Contents of /messaging/manakai/lib/Message/Header/RFC822.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Thu Jul 4 06:38:21 2002 UTC (22 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.5: +10 -2 lines
2002-07-04  Wakaba <w@suika.fam.cx>

	* Util.pm (encode_printable_string, decode_printable_string,
	encode_t71_string, decode_t71_string, encode_restricted_rfc822,
	decode_restricted_rfc822): New functions.

1 wakaba 1.1
2     =head1 NAME
3    
4     Message::Header::RFC822 --- Internet Messages -- Definition
5     for RFC822 Namespaces of Header Fields
6    
7     =cut
8    
9     package Message::Header::RFC822;
10     use strict;
11     use vars qw($VERSION);
12 wakaba 1.6 $VERSION=do{my @r=(q$Revision: 1.5 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
13 wakaba 1.1 require Message::Header::Default;
14    
15     our %OPTION = %Message::Header::Default::OPTION;
16     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822';
17     $OPTION{namespace_phname} = 'rfc822';
18     $OPTION{namespace_phname_goodcase} = 'RFC822';
19    
20     $OPTION{case_sensible} = 0;
21    
22     $OPTION{goodcase} = {
23     fax => 'FAX',
24     'pics-label' => 'PICS-Label',
25     'list-url' => 'List-URL',
26     'list-id' => 'List-ID',
27     'message-id' => 'Message-ID',
28     'mime-version' => 'MIME-Version',
29     'nic' => 'NIC',
30     'nntp-posting-date' => 'NNTP-Posting-Date',
31     'nntp-posting-host' => 'NNTP-Posting-Host',
32     url => 'URL',
33     'x-dearfriend' => 'X-DearFriend',
34     'x-jsmail-priority' => 'X-JsMail-Priority',
35     'x-mime-autoconverted' => 'X-MIME-Autoconverted',
36     'x-mimeole' => 'X-MimeOLE',
37 wakaba 1.3 'x-ml-count' => 'X-ML-Count',
38     'x-ml-info' => 'X-ML-Info',
39     'x-ml-name' => 'X-ML-Name',
40 wakaba 1.1 'x-msmail-priority' => 'X-MSMail-Priority',
41     'x-nntp-posting-date' => 'X-NNTP-Posting-Date',
42     'x-nntp-posting-host' => 'X-NNTP-Posting-Host',
43     'x-uidl' => 'X-UIDL',
44     'x-uri' => 'X-URI',
45     'x-url' => 'X-URL',
46     };
47     $OPTION{to_be_goodcase} = \&_goodcase;
48    
49     $OPTION{value_type} = {
50     ':default' => ['Message::Field::Unstructured'],
51    
52     date => ['Message::Field::Date'],
53    
54     received => ['Message::Field::Received'],
55     'x-received' => ['Message::Field::Received'],
56    
57     archive => ['Message::Field::ValueParams'],
58     'auto-submitted' => ['Message::Field::ValueParams'],
59     'injector-info' => ['Message::Field::ValueParams'],
60     p3p => ['Message::Field::Params'],
61     'posted-and-mailed' => ['Message::Field::ValueParams'],
62     'x-face-type' => ['Message::Field::ValueParams'],
63     'x-mozilla-draft-info' => ['Message::Field::ValueParams'],
64    
65     ## A message id
66     'message-id' => ['Message::Field::MsgID'],
67     'resent-message-id' => ['Message::Field::MsgID'],
68    
69     ## Numeric value
70     lines => ['Message::Field::Numval'],
71     'max-forwards' => ['Message::Field::Numval'],
72     'mime-version' => ['Message::Field::Numval'],
73     'x-jsmail-priority' => ['Message::Field::Numval'],
74     'x-mail-count' => ['Message::Field::Numval'],
75     'x-ml-count' => ['Message::Field::Numval'],
76     'x-priority' => ['Message::Field::Numval'],
77    
78     path => ['Message::Field::Path'],
79     'user-agent' => ['Message::Field::UA'],
80 wakaba 1.3 'x-shimbun-agent' => ['Message::Field::UA'],
81 wakaba 1.1
82     subject => ['Message::Field::Subject'],
83     'x-nsubject' => ['Message::Field::Subject'],
84    
85 wakaba 1.4 'x-face' => ['Message::Field::XFace'],
86 wakaba 1.1 };
87     for (qw(cancel-lock disposition-notification-options encoding
88     importance pics-label precedence message-type
89 wakaba 1.4 priority x-list-id sensitivity x-msmail-priority xref))
90 wakaba 1.1 {$OPTION{value_type}->{$_} = ['Message::Field::Structured']}
91     for (qw(abuse-reports-to apparently-to approved approved-by bcc cc complaints-to
92     delivered-to disposition-notification-to envelope-to
93     errors-to from mail-copies-to mail-followup-to mail-reply-to
94     notice-requested-upon-delivery-to read-receipt-to register-mail-reply-requested-by
95     reply-to return-path
96     return-receipt-to return-receipt-requested-to sender to x-abuse-reports-to
97 wakaba 1.2 x-admin x-approved x-beenthere x-biglobe-sender x-confirm-reading-to
98 wakaba 1.1 x-complaints-to x-envelope-from x-envelope-sender
99     x-envelope-to x-ml-address x-ml-command x-ml-to x-nfrom x-nto
100     x-rcpt-to x-sender x-x-sender))
101     {$OPTION{value_type}->{$_} = ['Message::Field::Addresses']}
102     for (qw(client-date date date-received delivery-date expires
103     expire-date nntp-posting-date posted posted-date received-date
104 wakaba 1.5 reply-by resent-date x-originalarrivaltime x-original-date x-tcup-date))
105 wakaba 1.1 {$OPTION{value_type}->{$_} = ['Message::Field::Date']}
106     for (qw(article-updates in-reply-to
107     obsoletes references replaces see-also supersedes))
108     {$OPTION{value_type}->{$_} = ['Message::Field::MsgIDs']}
109     for (qw(encrypted followup-to keywords uri newsgroups posted-to))
110     {$OPTION{value_type}->{$_} = ['Message::Field::CSV']}
111     for (qw(x-brother x-boss x-classmate x-daughter x-dearfriend x-favoritesong
112     x-friend x-me
113     x-moe x-respect
114     x-sublimate x-son x-sister x-wife))
115     {$OPTION{value_type}->{$_} =[ 'Message::Field::CSV']} ## NOT M::F::XMOE!
116     for (qw(url x-home-page x-http_referer
117     x-info x-pgp-key x-ml-url x-uri x-url x-web))
118     {$OPTION{value_type}->{$_} = ['Message::Field::URI']}
119    
120     $OPTION{uri_mailto_safe} = {
121     ## 1 all (no check) 2 no trace & bcc & from
122     ## 3 no sender's info 4 (default) (currently not used)
123     ## 5 only a few
124     ':default' => 4,
125     'cc' => 5,
126     'bcc' => 1,
127     'body' => 1, ## Not entity body, but "body:" field.
128     'comments' => 5,
129     'date' => 1,
130     'from' => 1,
131     'keywords' => 5,
132     'list-id' => 1,
133     'mail-from' => 1,
134     'message-id' => 1,
135     'mime-version' => 1,
136     'received' => 1,
137     'return-path' => 1,
138     'sender' => 1,
139     'subject' => 5,
140     'summary' => 5,
141     'to' => 5,
142     'user-agent' => 3,
143     'x-face' => 2,
144     'x-mailer' => 3,
145     'x-nsubject' => 5,
146     'x-received' => 1,
147     'x400-received' => 1,
148     };
149    
150 wakaba 1.6 $OPTION{field}->{bcc} = {
151     empty_body => 1,
152     };
153     $OPTION{field}->{'incomplete-copy'} = { ## RFC 2156
154     empty_body => 1,
155     };
156    
157 wakaba 1.1 $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
158     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
159    
160     ## $self->_goodcase ($namespace_package_name, $field_name, \%option)
161     sub _goodcase ($$$\%) {
162     no strict 'refs';
163     my $self = shift;
164     my ($nspack, $name, $option) = @_;
165     return $name if $option->{format} =~ /uri-url-mailto/;
166     if ($option->{format} =~ /mail-rfc822/) {
167     if ($name eq 'cc' || $name eq 'bcc') {
168     return $name;
169     }
170     }
171     if (${$nspack.'::OPTION'}{goodcase}->{$name}) {
172     return ${$nspack.'::OPTION'}{goodcase}->{$name};
173     }
174     $name =~ s/(?:^|-)[a-z]/uc $&/ge;
175     $name;
176     }
177    
178     package Message::Header::RFC822::Resent;
179     our %OPTION = %Message::Header::RFC822::OPTION;
180     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822:resent';
181     $OPTION{namespace_phname} = 'resent';
182     $OPTION{namespace_phname_goodcase} = 'Resent';
183     $OPTION{namespace_phname_regex} = 'resent';
184    
185     $OPTION{uri_mailto_safe} = {
186     ':default' => 1,
187     };
188    
189     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
190     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
191    
192     package Message::Header::RFC822::Original;
193     our %OPTION = %Message::Header::RFC822::OPTION;
194     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822:original';
195     $OPTION{namespace_phname} = 'original';
196     $OPTION{namespace_phname_goodcase} = 'Original';
197    
198 wakaba 1.6 $OPTION{value_type} = { %{ $OPTION{value_type} } };
199 wakaba 1.1 $OPTION{value_type}->{recipient} = ['Message::Header::Structured'];
200    
201     $OPTION{uri_mailto_safe} = {
202     ':default' => 1,
203     };
204    
205     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
206     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
207    
208     package Message::Header::RFC822::Content;
209     our %OPTION = %Message::Header::RFC822::OPTION;
210     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822:content';
211     $OPTION{namespace_phname} = 'content';
212     $OPTION{namespace_phname_goodcase} = 'Content';
213     $OPTION{namespace_phname_regex} = 'content';
214    
215     $OPTION{goodcase} = {
216     'id' => 'ID',
217     'md5' => 'MD5',
218     'sgml-entity' => 'SGML-Entity',
219     };
220    
221     $OPTION{value_type} = {
222     ':default' => ['Message::Field::Unstructured'],
223     alias => ['Message::Field::URI'],
224     base => ['Message::Field::URI'],
225     disposition => ['Message::Field::ValueParams'],
226     duration => ['Message::Field::Numval'],
227     encoding => ['Message::Field::CSV'],
228     features => ['Message::Field::Structured'],
229     id => ['Message::Field::MsgID'],
230     language => ['Message::Field::CSV'],
231     length => ['Message::Field::Numval'],
232     location => ['Message::Field::URI'],
233     md5 => ['Message::Field::Structured'],
234     range => ['Message::Field::Structured'],
235     'script-type' => ['Message::Field::ContentType'],
236     'style-type' => ['Message::Field::ContentType'],
237     'transfer-encoding' => ['Message::Field::ValueParams'],
238     type => ['Message::Field::ContentType'],
239     version => ['Message::Field::Structured'],
240 wakaba 1.3 'x-properties' => ['Message::Field::Params'],
241 wakaba 1.1 };
242    
243     $OPTION{uri_mailto_safe} = {
244     ':default' => 1,
245     };
246    
247     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
248     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
249    
250     package Message::Header::RFC822::List;
251     our %OPTION = %Message::Header::RFC822::OPTION;
252     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822:list';
253     $OPTION{namespace_phname} = 'list';
254     $OPTION{namespace_phname_goodcase} = 'List';
255    
256     $OPTION{goodcase} = {
257     'id' => 'ID',
258     };
259    
260     $OPTION{value_type} = {
261     ':default' => ['Message::Field::Unstructured'],
262    
263 wakaba 1.4 id => ['Message::Field::ListID'],
264 wakaba 1.1 software => ['Message::Field::UA'],
265    
266     archive => ['Message::Field::CSV'],
267     digest => ['Message::Field::CSV'],
268     help => ['Message::Field::CSV'],
269     owner => ['Message::Field::CSV'],
270     post => ['Message::Field::CSV'],
271     subscribe => ['Message::Field::CSV'],
272     unsubscribe => ['Message::Field::CSV'],
273     url => ['Message::Field::CSV'],
274     };
275    
276     $OPTION{uri_mailto_safe} = {
277     ':default' => 1,
278     };
279    
280     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
281     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
282    
283     =head1 LICENSE
284    
285     Copyright 2002 wakaba E<lt>w@suika.fam.cxE<gt>.
286    
287     This program is free software; you can redistribute it and/or modify
288     it under the terms of the GNU General Public License as published by
289     the Free Software Foundation; either version 2 of the License, or
290     (at your option) any later version.
291    
292     This program is distributed in the hope that it will be useful,
293     but WITHOUT ANY WARRANTY; without even the implied warranty of
294     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
295     GNU General Public License for more details.
296    
297     You should have received a copy of the GNU General Public License
298     along with this program; see the file COPYING. If not, write to
299     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
300     Boston, MA 02111-1307, USA.
301    
302     =head1 CHANGE
303    
304     See F<ChangeLog>.
305 wakaba 1.6 $Date: 2002/07/03 23:39:15 $
306 wakaba 1.1
307     =cut
308    
309     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24