1Mail::Message::Field::AUtsterribCuotnet(r3i)buted Perl DMoaciulm:e:nMteastsiaogne::Field::Attribute(3)
2
3
4

NAME

6       Mail::Message::Field::Attribute - one attribute of a full field
7

INHERITANCE

9        Mail::Message::Field::Attribute
10          is a Mail::Reporter
11

SYNOPSIS

13        my $field    = $msg->head->get('Content-Disposition') or return;
14        my $full     = $field->study;   # full understanding in unicode
15        my $filename = $full->attribute('filename')           or return;
16
17        print ref $filename;     # this class name
18        print $filename;         # the attributes content in utf-8
19        print $filename->value;  # same
20        print $filename->string; # print string as was found in the file
21        $filename->print(\*OUT); # print as was found in the file
22

DESCRIPTION

24       Attributes within MIME fields can be quite complex, and therefore be
25       slow and consumes a lot of memory.  The Mail::Message::Field::Fast and
26       Mail::Message::Field::Flex simplify them the attributes a lot, which
27       may result in erroneous behavior in rare cases.  With the increase of
28       non-western languages on Internet, the need for the complex headers
29       becomes more and more in demand.
30
31       A "Mail::Message::Field::Attribute" can be found in any structured
32       Mail::Message::Field::Full header field.
33
34       Extends "DESCRIPTION" in Mail::Reporter.
35

OVERLOADED

37       overload: comparison
38           When the second argument is a field, then both attribute name
39           (case-sensitive) and the decoded value must be the same.
40           Otherwise, the value is compared.
41
42       overload: stringification
43           Returns the decoded content of the attribute.
44

METHODS

46       Extends "METHODS" in Mail::Reporter.
47
48   Constructors
49       Extends "Constructors" in Mail::Reporter.
50
51       Mail::Message::Field::Attribute->new( <$name, [$value] | STRING>,
52       %options )
53           Create a new attribute $name with the optional $value.  If no
54           $value is specified, the first argument of this method is inspected
55           for an equals sign '='.  If that character is present, the argument
56           is taken as STRING, containing a preformatted attribute which is
57           processed.  Otherwise, the argument is taken as name without
58           $value: set the value later with value().
59
60           Whether encoding takes place depends on the %options and the
61           existence of non-ascii characters in the $value.  The $name can
62           only contain ascii characters, hence is never encoded.
63
64           To speed things up, attributes are not derived from the
65           Mail::Reporter base-class.
66
67            -Option           --Defined in     --Default
68             charset                             'us-ascii'
69             language                            undef
70             log                Mail::Reporter   'WARNINGS'
71             trace              Mail::Reporter   'WARNINGS'
72             use_continuations                   <true>
73
74           charset => STRING
75             The $value is translated from utf-8 (Perl internal) to this
76             character set, and the resulting string is encoded if required.
77             "us-ascii" is the normal encoding for e-mail.  Valid character
78             sets can be found with Encode::encodings(':all').
79
80           language => STRING
81             RFC2231 adds the possibility to specify a language with the
82             field.  When no language is specified, none is included in the
83             encoding.  Valid language names are defined by RFC2130.  This
84             module has only limited support for this feature.
85
86           log => LEVEL
87           trace => LEVEL
88           use_continuations => BOOLEAN
89             Continuations are used to break-up long parameters into pieces
90             which are no longer than 76 characters. Encodings are specified
91             in RFC2231, but not supported by some Mail User Agents.
92
93           example:
94
95            my $fn    = Mail::Message::Field::Attribute
96                           ->new(filename => 'xyz');
97
98            my $fattr = 'Mail::Message::Field::Attribute';  # abbrev
99            my $fn    = $fattr->new
100              ( filename => "Re\xC7u"
101              , charset  => 'iso-8859-15'
102              , language => 'nl-BE'
103              );
104            print $fn;
105              # -->  filename*=iso-8859-15'nl-BE'Re%C7u
106
107   Error handling
108       Extends "Error handling" in Mail::Reporter.
109
110       $obj->AUTOLOAD()
111           Inherited, see "Error handling" in Mail::Reporter
112
113       $obj->addReport($object)
114           Inherited, see "Error handling" in Mail::Reporter
115
116       $obj->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level,
117       $callback] )
118       Mail::Message::Field::Attribute->defaultTrace( [$level]|[$loglevel,
119       $tracelevel]|[$level, $callback] )
120           Inherited, see "Error handling" in Mail::Reporter
121
122       $obj->errors()
123           Inherited, see "Error handling" in Mail::Reporter
124
125       $obj->log( [$level, [$strings]] )
126       Mail::Message::Field::Attribute->log( [$level, [$strings]] )
127           Inherited, see "Error handling" in Mail::Reporter
128
129       $obj->logPriority($level)
130       Mail::Message::Field::Attribute->logPriority($level)
131           Inherited, see "Error handling" in Mail::Reporter
132
133       $obj->logSettings()
134           Inherited, see "Error handling" in Mail::Reporter
135
136       $obj->notImplemented()
137           Inherited, see "Error handling" in Mail::Reporter
138
139       $obj->report( [$level] )
140           Inherited, see "Error handling" in Mail::Reporter
141
142       $obj->reportAll( [$level] )
143           Inherited, see "Error handling" in Mail::Reporter
144
145       $obj->trace( [$level] )
146           Inherited, see "Error handling" in Mail::Reporter
147
148       $obj->warnings()
149           Inherited, see "Error handling" in Mail::Reporter
150
151   Cleanup
152       Extends "Cleanup" in Mail::Reporter.
153
154       $obj->DESTROY()
155           Inherited, see "Cleanup" in Mail::Reporter
156
157   The attribute
158       $obj->addComponent(STRING)
159           A component is a parameter as defined by RFC2045, optionally using
160           encoding or continuations as defined by RFC2231.  Components of an
161           attribute are found when a field is being parsed.  The RFCs are
162           very strict on valid characters, but we cannot be: you have to
163           accept what is coming in if you can.
164
165           example:
166
167            my $param = Mail::Message::Field::Attribute->new;
168            $param->addComponent("filename*=iso10646'nl-BE'%Re\47u");
169
170       $obj->charset()
171           Returns the character set which is used for this parameter.  If any
172           component is added which contains character set information, this
173           is directly available.  Be warned that a character-set is case
174           insensitive.
175
176       $obj->language()
177           Returns the language which is defined in the argument.  If no
178           language is defined "undef" is returned, which should be
179           interpreted as "ANY"
180
181       $obj->name()
182           Returns the name of this attribute.
183
184       $obj->string()
185           Returns the parameter as reference to an array of lines.  When only
186           one line is returned, it may be short enough to fit on the same
187           line with other components of the header field.
188
189       $obj->value( [STRING] )
190           Returns the value of this parameter, optionally after setting it
191           first.
192
193   Attribute encoding
194       $obj->decode()
195           Translate all known continuations into a value.  The produced value
196           is returned and may be utf-8 encoded or a plain string.
197
198       $obj->encode()
199
200   Internals
201       $obj->mergeComponent($attribute)
202           Merge the components from the specified attribute into this
203           attribute.  This is needed when components of the same attribute
204           are created separately.  Merging is required by the field parsing.
205

DIAGNOSTICS

207       Warning: Illegal character in parameter name '$name'
208           The specified parameter name contains characters which are not
209           permitted by the RFCs.  You can better change the name into
210           something which is accepted, or risk applications to corrupt or
211           ignore the message.
212
213       Error: Package $package does not implement $method.
214           Fatal error: the specific package (or one of its superclasses) does
215           not implement this method where it should. This message means that
216           some other related classes do implement this method however the
217           class at hand does not.  Probably you should investigate this and
218           probably inform the author of the package.
219
220       Error: Too late to merge: value already changed.
221

SEE ALSO

223       This module is part of Mail-Message distribution version 3.013, built
224       on June 24, 2023. Website: http://perl.overmeer.net/CPAN/
225

LICENSE

227       Copyrights 2001-2023 by [Mark Overmeer <markov@cpan.org>]. For other
228       contributors see ChangeLog.
229
230       This program is free software; you can redistribute it and/or modify it
231       under the same terms as Perl itself.  See http://dev.perl.org/licenses/
232
233
234
235perl v5.38.0                      2023-07-20Mail::Message::Field::Attribute(3)
Impressum