23 |
%DEFAULT = ( |
%DEFAULT = ( |
24 |
use_parameter_extension => 1, |
use_parameter_extension => 1, |
25 |
value_default => '', |
value_default => '', |
26 |
value_no_regex => qr/(?:$)(?:^)/, |
value_no_regex => qr/(?!)/, |
27 |
value_regex => qr/[\x00-\xFF]+/, |
value_regex => qr/[\x00-\xFF]+/, |
28 |
|
value_unsafe_rule => 'NON_token_wsp', |
29 |
value_type => {'*DEFAULT' => ':none:', |
value_type => {'*DEFAULT' => ':none:', |
30 |
}, |
}, |
31 |
); |
); |
154 |
sub stringify ($;%) { |
sub stringify ($;%) { |
155 |
my $self = shift; |
my $self = shift; |
156 |
my $param = $self->SUPER::stringify (@_); |
my $param = $self->SUPER::stringify (@_); |
157 |
$self->value ().($param? '; '.$param: ''); |
$self->value_as_string (@_).($param? '; '.$param: ''); |
158 |
} |
} |
159 |
|
|
160 |
=head2 $self->value ([$new_value]) |
=head2 $self->value ([$new_value]) |
163 |
|
|
164 |
=cut |
=cut |
165 |
|
|
166 |
sub value ($;$) { |
sub value ($;$%) { |
167 |
my $self = shift; |
my $self = shift; |
168 |
my $new_value = shift; |
my $new_value = shift; |
169 |
|
my %option = @_; |
170 |
if ($new_value && $new_value !~ m#$self->{option}->{value_no_regex}#) { |
if ($new_value && $new_value !~ m#$self->{option}->{value_no_regex}#) { |
171 |
$self->{value} = $new_value; |
$self->{value} = $new_value; |
172 |
} |
} |
173 |
$self->_quote_unsafe_string ($self->{value}); |
#my $unsafe_rule = $option{unsafe_rule} || $self->{option}->{value_unsafe_rule}; |
174 |
|
#$self->_quote_unsafe_string ($self->{value}, unsafe => $unsafe_rule); |
175 |
|
$self->{value}; |
176 |
|
} |
177 |
|
|
178 |
|
=head2 $self->value_as_string ([%options]) |
179 |
|
|
180 |
|
Returns value. If necessary, quoted and encoded in |
181 |
|
message format. Same as C<stringify> except that |
182 |
|
only first "value" is outputed. |
183 |
|
|
184 |
|
=cut |
185 |
|
|
186 |
|
sub value_as_string ($;%) { |
187 |
|
my $self = shift; |
188 |
|
my %option = @_; |
189 |
|
my (%e) = &{$self->{option}->{hook_encode_string}} ($self, |
190 |
|
$self->{value}, type => 'phrase'); |
191 |
|
my $unsafe_rule = $option{unsafe_rule} || $self->{option}->{value_unsafe_rule}; |
192 |
|
$self->_quote_unsafe_string ($e{value}, unsafe => $unsafe_rule); |
193 |
} |
} |
194 |
|
|
195 |
|
|