/[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.3 - (hide annotations) (download)
Sun Jun 9 11:20:24 2002 UTC (22 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.2: +7 -2 lines
2002-06-09  wakaba <w@suika.fam.cx>

	* Entity.pm:
	- (stringify): Minimumize MIME charset name when MIME'izing.
	- (mime-entity): New 'format' type.
	- (default_media_subtype): New option.  Now 'default_media_type'
	is used for only (narrower meaning of) media type.
	- (content_type): See 'default_media_type' and
	'default_media_subtype'.  (Was hardcoded as 'text/plain'.)
	- (option): '-resucrive': new option.
	* Header.pm (parse, parse_array): Don't discard invalid
	line (non-'field' line).  (Treat as "X-Unknown" field.)

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.3 $VERSION=do{my @r=(q$Revision: 1.2 $=~/\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     };
86     for (qw(cancel-lock disposition-notification-options encoding
87     importance pics-label precedence message-type
88     priority x-list-id sensitivity x-face x-msmail-priority xref))
89     {$OPTION{value_type}->{$_} = ['Message::Field::Structured']}
90     for (qw(abuse-reports-to apparently-to approved approved-by bcc cc complaints-to
91     delivered-to disposition-notification-to envelope-to
92     errors-to from mail-copies-to mail-followup-to mail-reply-to
93     notice-requested-upon-delivery-to read-receipt-to register-mail-reply-requested-by
94     reply-to return-path
95     return-receipt-to return-receipt-requested-to sender to x-abuse-reports-to
96 wakaba 1.2 x-admin x-approved x-beenthere x-biglobe-sender x-confirm-reading-to
97 wakaba 1.1 x-complaints-to x-envelope-from x-envelope-sender
98     x-envelope-to x-ml-address x-ml-command x-ml-to x-nfrom x-nto
99     x-rcpt-to x-sender x-x-sender))
100     {$OPTION{value_type}->{$_} = ['Message::Field::Addresses']}
101     for (qw(client-date date date-received delivery-date expires
102     expire-date nntp-posting-date posted posted-date received-date
103     reply-by resent-date x-originalarrivaltime x-tcup-date))
104     {$OPTION{value_type}->{$_} = ['Message::Field::Date']}
105     for (qw(article-updates in-reply-to
106     obsoletes references replaces see-also supersedes))
107     {$OPTION{value_type}->{$_} = ['Message::Field::MsgIDs']}
108     for (qw(encrypted followup-to keywords uri newsgroups posted-to))
109     {$OPTION{value_type}->{$_} = ['Message::Field::CSV']}
110     for (qw(x-brother x-boss x-classmate x-daughter x-dearfriend x-favoritesong
111     x-friend x-me
112     x-moe x-respect
113     x-sublimate x-son x-sister x-wife))
114     {$OPTION{value_type}->{$_} =[ 'Message::Field::CSV']} ## NOT M::F::XMOE!
115     for (qw(url x-home-page x-http_referer
116     x-info x-pgp-key x-ml-url x-uri x-url x-web))
117     {$OPTION{value_type}->{$_} = ['Message::Field::URI']}
118    
119     $OPTION{uri_mailto_safe} = {
120     ## 1 all (no check) 2 no trace & bcc & from
121     ## 3 no sender's info 4 (default) (currently not used)
122     ## 5 only a few
123     ':default' => 4,
124     'cc' => 5,
125     'bcc' => 1,
126     'body' => 1, ## Not entity body, but "body:" field.
127     'comments' => 5,
128     'date' => 1,
129     'from' => 1,
130     'keywords' => 5,
131     'list-id' => 1,
132     'mail-from' => 1,
133     'message-id' => 1,
134     'mime-version' => 1,
135     'received' => 1,
136     'return-path' => 1,
137     'sender' => 1,
138     'subject' => 5,
139     'summary' => 5,
140     'to' => 5,
141     'user-agent' => 3,
142     'x-face' => 2,
143     'x-mailer' => 3,
144     'x-nsubject' => 5,
145     'x-received' => 1,
146     'x400-received' => 1,
147     };
148    
149     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
150     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
151    
152     ## $self->_goodcase ($namespace_package_name, $field_name, \%option)
153     sub _goodcase ($$$\%) {
154     no strict 'refs';
155     my $self = shift;
156     my ($nspack, $name, $option) = @_;
157     return $name if $option->{format} =~ /uri-url-mailto/;
158     if ($option->{format} =~ /mail-rfc822/) {
159     if ($name eq 'cc' || $name eq 'bcc') {
160     return $name;
161     }
162     }
163     if (${$nspack.'::OPTION'}{goodcase}->{$name}) {
164     return ${$nspack.'::OPTION'}{goodcase}->{$name};
165     }
166     $name =~ s/(?:^|-)[a-z]/uc $&/ge;
167     $name;
168     }
169    
170     package Message::Header::RFC822::Resent;
171     our %OPTION = %Message::Header::RFC822::OPTION;
172     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822:resent';
173     $OPTION{namespace_phname} = 'resent';
174     $OPTION{namespace_phname_goodcase} = 'Resent';
175     $OPTION{namespace_phname_regex} = 'resent';
176    
177     $OPTION{uri_mailto_safe} = {
178     ':default' => 1,
179     };
180    
181     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
182     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
183    
184     package Message::Header::RFC822::Original;
185     our %OPTION = %Message::Header::RFC822::OPTION;
186     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822:original';
187     $OPTION{namespace_phname} = 'original';
188     $OPTION{namespace_phname_goodcase} = 'Original';
189    
190     $OPTION{value_type}->{recipient} = ['Message::Header::Structured'];
191    
192     $OPTION{uri_mailto_safe} = {
193     ':default' => 1,
194     };
195    
196     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
197     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
198    
199     package Message::Header::RFC822::Content;
200     our %OPTION = %Message::Header::RFC822::OPTION;
201     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822:content';
202     $OPTION{namespace_phname} = 'content';
203     $OPTION{namespace_phname_goodcase} = 'Content';
204     $OPTION{namespace_phname_regex} = 'content';
205    
206     $OPTION{goodcase} = {
207     'id' => 'ID',
208     'md5' => 'MD5',
209     'sgml-entity' => 'SGML-Entity',
210     };
211    
212     $OPTION{value_type} = {
213     ':default' => ['Message::Field::Unstructured'],
214     alias => ['Message::Field::URI'],
215     base => ['Message::Field::URI'],
216     disposition => ['Message::Field::ValueParams'],
217     duration => ['Message::Field::Numval'],
218     encoding => ['Message::Field::CSV'],
219     features => ['Message::Field::Structured'],
220     id => ['Message::Field::MsgID'],
221     language => ['Message::Field::CSV'],
222     length => ['Message::Field::Numval'],
223     location => ['Message::Field::URI'],
224     md5 => ['Message::Field::Structured'],
225     range => ['Message::Field::Structured'],
226     'script-type' => ['Message::Field::ContentType'],
227     'style-type' => ['Message::Field::ContentType'],
228     'transfer-encoding' => ['Message::Field::ValueParams'],
229     type => ['Message::Field::ContentType'],
230     version => ['Message::Field::Structured'],
231 wakaba 1.3 'x-properties' => ['Message::Field::Params'],
232 wakaba 1.1 };
233    
234     $OPTION{uri_mailto_safe} = {
235     ':default' => 1,
236     };
237    
238     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
239     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
240    
241     package Message::Header::RFC822::List;
242     our %OPTION = %Message::Header::RFC822::OPTION;
243     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822:list';
244     $OPTION{namespace_phname} = 'list';
245     $OPTION{namespace_phname_goodcase} = 'List';
246    
247     $OPTION{goodcase} = {
248     'id' => 'ID',
249     };
250    
251     $OPTION{value_type} = {
252     ':default' => ['Message::Field::Unstructured'],
253    
254     id => ['Message::Field::Structured'],
255     software => ['Message::Field::UA'],
256    
257     archive => ['Message::Field::CSV'],
258     digest => ['Message::Field::CSV'],
259     help => ['Message::Field::CSV'],
260     owner => ['Message::Field::CSV'],
261     post => ['Message::Field::CSV'],
262     subscribe => ['Message::Field::CSV'],
263     unsubscribe => ['Message::Field::CSV'],
264     url => ['Message::Field::CSV'],
265     };
266    
267     $OPTION{uri_mailto_safe} = {
268     ':default' => 1,
269     };
270    
271     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
272     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
273    
274     =head1 LICENSE
275    
276     Copyright 2002 wakaba E<lt>w@suika.fam.cxE<gt>.
277    
278     This program is free software; you can redistribute it and/or modify
279     it under the terms of the GNU General Public License as published by
280     the Free Software Foundation; either version 2 of the License, or
281     (at your option) any later version.
282    
283     This program is distributed in the hope that it will be useful,
284     but WITHOUT ANY WARRANTY; without even the implied warranty of
285     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
286     GNU General Public License for more details.
287    
288     You should have received a copy of the GNU General Public License
289     along with this program; see the file COPYING. If not, write to
290     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
291     Boston, MA 02111-1307, USA.
292    
293     =head1 CHANGE
294    
295     See F<ChangeLog>.
296 wakaba 1.3 $Date: 2002/05/29 11:05:53 $
297 wakaba 1.1
298     =cut
299    
300     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24