30 |
-_HASH_NAME => 'value', |
-_HASH_NAME => 'value', |
31 |
-_METHODS => [qw|field field_exist field_type add replace count delete subject id is|], |
-_METHODS => [qw|field field_exist field_type add replace count delete subject id is|], |
32 |
-_MEMBERS => [qw|value|], |
-_MEMBERS => [qw|value|], |
|
-M_namsepace_prefix_regex => qr/(?!)/, |
|
33 |
-_VALTYPE_DEFAULT => ':default', |
-_VALTYPE_DEFAULT => ':default', |
34 |
-by => 'name', ## (Reserved for method level option) |
-by => 'name', ## (Reserved for method level option) |
35 |
-field_format_pattern => '%s: %s', |
-field_format_pattern => '%s: %s', |
40 |
#-format => 'mail-rfc2822', |
#-format => 'mail-rfc2822', |
41 |
-linebreak_strict => 0, ## Not implemented completely |
-linebreak_strict => 0, ## Not implemented completely |
42 |
-line_length_max => 60, ## For folding |
-line_length_max => 60, ## For folding |
43 |
-ns_default_uri => $Message::Header::Default::OPTION{namespace_uri}, |
#ns_default_phuri |
44 |
-output_bcc => 0, |
-output_bcc => 0, |
45 |
-output_folding => 1, |
-output_folding => 1, |
46 |
-output_mail_from => 0, |
-output_mail_from => 0, |
58 |
p3p => ['Message::Field::Params'], |
p3p => ['Message::Field::Params'], |
59 |
link => ['Message::Field::ValueParams'], |
link => ['Message::Field::ValueParams'], |
60 |
|
|
|
'list-software' => ['Message::Field::UA'], |
|
61 |
'user-agent' => ['Message::Field::UA'], |
'user-agent' => ['Message::Field::UA'], |
62 |
server => ['Message::Field::UA'], |
server => ['Message::Field::UA'], |
63 |
}; |
}; |
|
for (qw(pics-label list-id status)) |
|
|
{$DEFAULT{-value_type}->{$_} = ['Message::Field::Structured']} |
|
|
## Not supported yet, but to be supported... |
|
|
# x-list: unstructured, ml name |
|
64 |
for (qw(date expires)) |
for (qw(date expires)) |
65 |
{$DEFAULT{-value_type}->{$_} = ['Message::Field::Date']} |
{$DEFAULT{-value_type}->{$_} = ['Message::Field::Date']} |
66 |
for (qw(accept accept-charset accept-encoding accept-language uri)) |
for (qw(accept accept-charset accept-encoding accept-language uri)) |
122 |
$self->SUPER::_init (%$DEFAULT, %options); |
$self->SUPER::_init (%$DEFAULT, %options); |
123 |
$self->{value} = []; |
$self->{value} = []; |
124 |
$self->_ns_load_ph ('default'); |
$self->_ns_load_ph ('default'); |
|
$self->{ns}->{default_phuri} = $self->{ns}->{phname2uri}->{'default'}; |
|
125 |
$self->_ns_load_ph ('rfc822'); |
$self->_ns_load_ph ('rfc822'); |
126 |
$self->{ns}->{default_phuri} = $self->{ns}->{phname2uri}->{'rfc822'}; |
$self->{option}->{ns_default_phuri} = $self->{ns}->{phname2uri}->{'rfc822'} |
127 |
|
unless $self->{option}->{ns_default_phuri}; |
128 |
|
|
129 |
my @new_fields = (); |
my @new_fields = (); |
130 |
for my $name (keys %options) { |
for my $name (keys %options) { |
297 |
if ($s) { |
if ($s) { |
298 |
$l{$v->{name} . ':' . ( $option->{ns} || $v->{ns} ) } = 1; |
$l{$v->{name} . ':' . ( $option->{ns} || $v->{ns} ) } = 1; |
299 |
} else { |
} else { |
300 |
$l{$v->{name} .':'. ( $option->{ns} || $self->{ns}->{default_phuri} ) } = 1; |
$l{$v->{name} .':'. ( $option->{ns} || $self->{option}->{ns_default_phuri} ) } = 1; |
301 |
} |
} |
302 |
} |
} |
303 |
return 1 if $l{$$i->{name} . ':' . $$i->{ns}}; |
return 1 if $l{$$i->{name} . ':' . $$i->{ns}}; |
318 |
${$_[1]}->{body}; |
${$_[1]}->{body}; |
319 |
} |
} |
320 |
} |
} |
321 |
|
*_add_return_value = \&_item_return_value; |
322 |
|
*_replace_return_value = \&_item_return_value; |
323 |
|
|
324 |
## Returns returned (new created) item value $name, \%option |
## Returns returned (new created) item value $name, \%option |
325 |
sub _item_new_value ($$\%) { |
sub _item_new_value ($$\%) { |
337 |
my $value = shift; return $value if ref $value; |
my $value = shift; return $value if ref $value; |
338 |
my %option = @_; |
my %option = @_; |
339 |
my $vtype; { no strict 'refs'; |
my $vtype; { no strict 'refs'; |
340 |
$vtype = ${&_NS_uri2phpackage ($option{ns}).'::OPTION'}{value_type}; |
my $vt = ${&_NS_uri2phpackage ($option{ns}).'::OPTION'}{value_type}; |
341 |
if (ref $vtype) { $vtype = $vtype->{$name} } |
if (ref $vt) { |
342 |
unless (ref $vtype) { $vtype = $vtype->{$self->{option}->{_VALTYPE_DEFAULT}} } |
$vtype = $vt->{$name} || $vt->{$self->{option}->{_VALTYPE_DEFAULT}}; |
343 |
|
} |
344 |
## For compatiblity. |
## For compatiblity. |
345 |
unless (ref $vtype) { $vtype = $self->{option}->{value_type}->{$name} |
unless (ref $vtype) { $vtype = $self->{option}->{value_type}->{$name} |
346 |
|| $self->{option}->{value_type}->{$self->{option}->{_VALTYPE_DEFAULT}} } |
|| $self->{option}->{value_type}->{$self->{option}->{_VALTYPE_DEFAULT}} } |
386 |
my $self = shift; |
my $self = shift; |
387 |
if (defined $_[0]) { |
if (defined $_[0]) { |
388 |
no strict 'refs'; |
no strict 'refs'; |
389 |
$self->{ns}->{default_phuri} = $_[0]; |
$self->{option}->{ns_default_phuri} = $_[0]; |
390 |
$self->_ns_load_ph (${&_NS_uri2phpackage ($self->{ns}->{default_phuri}).'::OPTION'}{namespace_phname}); |
$self->_ns_load_ph (${&_NS_uri2phpackage ($self->{option}->{ns_default_phuri}).'::OPTION'}{namespace_phname}); |
391 |
} |
} |
392 |
$self->{ns}->{default_phuri}; |
$self->{option}->{ns_default_phuri}; |
393 |
} |
} |
394 |
|
|
395 |
=item $hdr->add ($field-name, $field-body, [$name, $body, ...]) |
=item $hdr->add ($field-name, $field-body, [$name, $body, ...]) |
428 |
if (ref $value eq 'ARRAY') { |
if (ref $value eq 'ARRAY') { |
429 |
($value, %$value_option) = @$value; |
($value, %$value_option) = @$value; |
430 |
} |
} |
431 |
my $nsuri = $self->{ns}->{default_phuri}; |
my $nsuri = $self->{option}->{ns_default_phuri}; |
432 |
|
|
433 |
no strict 'refs'; |
no strict 'refs'; |
434 |
if ($value_option->{ns}) { |
if ($value_option->{ns}) { |
435 |
$nsuri = $value_option->{ns}; |
$nsuri = $value_option->{ns}; |
444 |
$nsuri = $self->{ns}->{phname2uri}->{$prefix}; |
$nsuri = $self->{ns}->{phname2uri}->{$prefix}; |
445 |
unless ($nsuri) { |
unless ($nsuri) { |
446 |
$name = $oprefix . '-' . $name; |
$name = $oprefix . '-' . $name; |
447 |
$nsuri = $self->{ns}->{default_phuri}; |
$nsuri = $self->{option}->{ns_default_phuri}; |
448 |
} |
} |
449 |
} |
} |
450 |
$name |
$name |
453 |
Carp::croak "$name: invalid field-name" |
Carp::croak "$name: invalid field-name" |
454 |
if $option->{field_name_validation} |
if $option->{field_name_validation} |
455 |
&& $name =~ /$REG{$option->{field_name_unsafe_rule}}/; |
&& $name =~ /$REG{$option->{field_name_unsafe_rule}}/; |
456 |
$value = $self->_parse_value ($name => $value, ns => $nsuri) if $$option{parse}; |
$value = $self->_parse_value ($name => $value, ns => $nsuri) |
457 |
|
if $$option{parse} || $$option{parse_all}; |
458 |
$$option{parse} = 0; |
$$option{parse} = 0; |
459 |
(1, $name.':'.$nsuri => {name => $name, body => $value, ns => $nsuri}); |
(1, $name.':'.$nsuri => {name => $name, body => $value, ns => $nsuri}); |
460 |
} |
} |
565 |
my $self = shift; |
my $self = shift; |
566 |
my $s = shift; |
my $s = shift; |
567 |
$s =~ s/^$REG{WSP}+//; $s =~ s/$REG{WSP}+$//; |
$s =~ s/^$REG{WSP}+//; $s =~ s/$REG{WSP}+$//; |
568 |
$s = lc $s ;#unless $self->{option}->{field_name_case_sensible}; |
$s = lc $s unless ${&_NS_uri2phpackage ($self->{option}->{ns_default_phuri}).'::OPTION'}{case_sensible}; |
569 |
$s; |
$s; |
570 |
} |
} |
571 |
|
|
608 |
my $oname; ## Outputed field-name |
my $oname; ## Outputed field-name |
609 |
my $prefix = ${$nspackage.'::OPTION'} {namespace_phname_goodcase} |
my $prefix = ${$nspackage.'::OPTION'} {namespace_phname_goodcase} |
610 |
|| $self->{ns}->{uri2phname}->{$nsuri}; |
|| $self->{ns}->{uri2phname}->{$nsuri}; |
611 |
$prefix = undef if $nsuri eq $self->{ns}->{default_phuri}; |
$prefix = undef if $nsuri eq $self->{option}->{ns_default_phuri}; |
612 |
my $gc = ${$nspackage.'::OPTION'} {to_be_goodcase}; |
my $gc = ${$nspackage.'::OPTION'} {to_be_goodcase}; |
613 |
if (ref $gc) { $oname = &$gc ($self, $nspackage, $name, \%option) } |
if (ref $gc) { $oname = &$gc ($self, $nspackage, $name, \%option) } |
614 |
else { $oname = $name } |
else { $oname = $name } |
719 |
$max = 20 if $max < 20; |
$max = 20 if $max < 20; |
720 |
|
|
721 |
my $l = $option{-initial_length} || 0; |
my $l = $option{-initial_length} || 0; |
722 |
$string =~ s{([\x09\x20][^\x09\x20]+)}{ |
$string =~ s{((?:^|[\x09\x20])[^\x09\x20]+)}{ |
723 |
my $s = $1; |
my $s = $1; |
724 |
if ($l + length $s > $max) { |
if ($l + length $s > $max) { |
725 |
$s = "\x0D\x0A\x20" . $s; |
$s = "\x0D\x0A\x20" . $s; |