10 |
use vars qw(%DEFAULT @ISA $VERSION); |
use vars qw(%DEFAULT @ISA $VERSION); |
11 |
$VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
$VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
12 |
|
|
13 |
require Message::Field::Structured; |
require Message::Body::Text; |
14 |
push @ISA, qw(Message::Field::Structured); |
push @ISA, qw(Message::Body::Text); |
15 |
require Message::Header; |
|
16 |
require Message::MIME::Charset; |
%DEFAULT = ( |
17 |
use overload '""' => sub { $_[0]->stringify }, |
-_METHODS => [qw|value|], |
18 |
fallback => 1; |
-_MEMBERS => [qw|_charset|], |
19 |
|
-body_default_charset => 'us-ascii', |
20 |
%DEFAULT = ( |
-body_default_charset_input => 'iso-2022-int-1', |
21 |
-_METHODS => [qw|value|], |
#encoding_after_encode |
22 |
-_MEDIA_TYPE => 'text/plain', |
#encoding_before_decode |
23 |
-_MEMBERS => [qw|_charset|], |
#fill_ct => 0, |
24 |
-body_default_charset => 'us-ascii', |
#hook_encode_string |
25 |
-body_default_charset_input => 'iso-2022-int-1', |
#hook_decode_string |
26 |
#encoding_after_encode |
-media_type => 'text', |
27 |
#encoding_before_decode |
-media_subtype => 'plain', |
28 |
-hook_encode_string => \&Message::Util::encode_body_string, |
-use_normalization => 1, |
29 |
-hook_decode_string => \&Message::Util::decode_body_string, |
-use_param_charset => 1, |
30 |
-parse_all => 0, |
); |
|
-use_normalization => 1, |
|
|
-use_param_charset => 1, |
|
|
); |
|
31 |
|
|
32 |
=head1 CONSTRUCTORS |
=head1 CONSTRUCTORS |
33 |
|
|
44 |
my %option = @_; |
my %option = @_; |
45 |
$self->SUPER::_init (%$DEFAULT, %option); |
$self->SUPER::_init (%$DEFAULT, %option); |
46 |
|
|
47 |
if (ref $option{header}) { |
unless (defined $self->{option}->{fill_ct}) { |
48 |
$self->{header} = $option{header}; |
$self->{option}->{fill_ct} = $self->{option}->{format} =~ /http|mime/; |
|
} |
|
|
if ($self->{option}->{format} =~ /http/) { |
|
|
$self->{option}->{use_normalization} = 0; |
|
49 |
} |
} |
50 |
} |
} |
51 |
|
|
91 |
|
|
92 |
=cut |
=cut |
93 |
|
|
94 |
sub header ($;$) { |
## Inherited |
|
my $self = shift; |
|
|
my $new_header = shift; |
|
|
if (ref $new_header) { |
|
|
$self->{header} = $new_header; |
|
|
#} elsif ($new_header) { |
|
|
# $self->{header} = Message::Header->parse ($new_header); |
|
|
} |
|
|
#unless ($self->{header}) { |
|
|
# $self->{header} = new Message::Header; |
|
|
#} |
|
|
$self->{header}; |
|
|
} |
|
95 |
|
|
96 |
=item $body->value ([$new_body]) |
=item $body->value ([$new_body]) |
97 |
|
|
100 |
|
|
101 |
=cut |
=cut |
102 |
|
|
103 |
sub value ($;$) { |
## Inherited |
|
my $self = shift; |
|
|
my $new_body = shift; |
|
|
if ($new_body) { |
|
|
$self->{value} = $new_body; |
|
|
} |
|
|
$self->{value}; |
|
|
} |
|
104 |
|
|
105 |
=head2 $self->stringify ([%option]) |
=head2 $self->stringify ([%option]) |
106 |
|
|
129 |
if ($Message::MIME::Charset::CHARSET{$charset || '*default'}->{mime_text}) { |
if ($Message::MIME::Charset::CHARSET{$charset || '*default'}->{mime_text}) { |
130 |
$e{value} =~ s/\x0D(?!\x0A)/\x0D\x0A/gs; |
$e{value} =~ s/\x0D(?!\x0A)/\x0D\x0A/gs; |
131 |
$e{value} =~ s/(?<!\x0D)\x0A/\x0D\x0A/gs; |
$e{value} =~ s/(?<!\x0D)\x0A/\x0D\x0A/gs; |
132 |
$e{value} .= "\x0D\x0A" unless $e{value} =~ /\x0D\x0A$/s; |
#$e{value} .= "\x0D\x0A" unless $e{value} =~ /\x0D\x0A$/s; |
133 |
} |
} |
134 |
} |
} |
135 |
} else { |
} else { |
139 |
if ($e{charset}) { |
if ($e{charset}) { |
140 |
unless (ref $ct) { |
unless (ref $ct) { |
141 |
$ct = $self->{header}->field ('content-type'); |
$ct = $self->{header}->field ('content-type'); |
142 |
$ct->value ($option{_MEDIA_TYPE}); |
$ct->value ($option{media_type}.'/'.$option{media_subtype}); |
143 |
} |
} |
144 |
$ct->replace (charset => $e{charset}); |
$ct->replace (charset => $e{charset}); |
145 |
} elsif (ref $ct) { |
} elsif (ref $ct) { |
146 |
$ct->replace (charset => $self->{option}->{body_default_charset}); |
$ct->replace (charset => $self->{option}->{body_default_charset}); |
147 |
|
} elsif ($option{fill_ct}) { |
148 |
|
$ct = $self->{header}->field ('content-type'); |
149 |
|
$ct->value ($option{media_type}.'/'.$option{media_subtype}); |
150 |
|
$ct->replace (Message::MIME::Charset::name_minimumize ($option{body_default_charset} => $e{value})); |
151 |
} |
} |
152 |
} |
} |
153 |
$e{value}; |
$e{value}; |
154 |
} |
} |
155 |
*as_string = \&stringify; |
*as_string = \&stringify; |
156 |
|
|
|
=head2 $self->option ($option_name) |
|
|
|
|
|
Returns/set (new) value of the option. |
|
|
|
|
|
=cut |
|
|
|
|
157 |
## Inherited: option, clone |
## Inherited: option, clone |
158 |
|
|
159 |
=head1 SEE ALSO |
=head1 SEE ALSO |