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