| Top |
A GMimeParserOptions is used to pass various options to GMimeParser and all of the various other parser functions in GMime.
void (*GMimeParserWarningFunc) (gint64 offset,GMimeParserWarning errcode,const gchar *item,gpointer user_data);
The function signature for a callback to g_mime_parser_options_set_warning_callback().
Prefer GMimeComplianceIssueFunc for new compliance reporting code. See GMimeParserWarning for guidance on when this callback is still useful.
GMimeParserOptions *
g_mime_parser_options_new (void);
Creates a new set of GMimeParserOptions.
GMimeParserOptions *
g_mime_parser_options_ref (GMimeParserOptions *options);
Atomically acquires a reference to options
. This shares the same settings;
concurrent changes to the settings still require external synchronization.
void
g_mime_parser_options_unref (GMimeParserOptions *options);
Atomically releases a reference to options
. The options and their owned
data are destroyed when the last reference is released.
GMimeParserOptions *
g_mime_parser_options_clone (GMimeParserOptions *options);
Creates an independent copy of the settings in options
. Unlike
g_mime_parser_options_ref() or g_boxed_copy(), this does not share settings.
Warning callback data remains borrowed; the clone does not copy its
destroy notification. The data must remain valid while the clone uses it.
GMimeParserOptions *
g_mime_parser_options_get_default (void);
Gets the default parser options.
The returned reference belongs to GMime. Use g_mime_parser_options_ref()
to retain it independently, or g_mime_parser_options_clone() for a copy.
int
g_mime_parser_options_get_max_address_group_depth
(GMimeParserOptions *options);
Gets the maximum number of nested address groups. The default is 3. A value of 0 prevents the parser from accepting group addresses.
void g_mime_parser_options_set_max_address_group_depth (GMimeParserOptions *options,int max_depth);
Sets the maximum number of nested address groups. Groups beyond this limit are rejected and reported through the parser warning callback.
int
g_mime_parser_options_get_max_mime_depth
(GMimeParserOptions *options);
Gets the maximum MIME nesting depth. The default is 1024. A value of 0 treats all multipart and embedded-message entities as leaves.
void g_mime_parser_options_set_max_mime_depth (GMimeParserOptions *options,int max_depth);
Sets the maximum MIME nesting depth. Containers at this depth are parsed as GMimePart objects, preserving their content without parsing it. Exceeding the limit is reported through the parser warning callback.
The parser currently uses recursion. Increasing the limit above its default may exhaust the call stack.
GMimeRfcComplianceMode
g_mime_parser_options_get_address_compliance_mode
(GMimeParserOptions *options);
Gets the compliance mode that should be used when parsing rfc822 addresses.
Note: Even in GMIME_RFC_COMPLIANCE_STRICT mode, the address parser is fairly liberal in what it accepts. Setting it to GMIME_RFC_COMPLIANCE_LOOSE just makes it try harder to deal with garbage input. GMIME_RFC_COMPLIANCE_LOOSER additionally accepts consecutive or trailing dots and escaped at-signs in local parts.
void g_mime_parser_options_set_address_compliance_mode (GMimeParserOptions *options,GMimeRfcComplianceMode mode);
Sets the compliance mode that should be used when parsing rfc822 addresses.
In general, you'll probably want this value to be GMIME_RFC_COMPLIANCE_LOOSE (the default) as it allows maximum interoperability with existing (broken) mail clients and other mail software such as sloppily written perl scripts (aka spambots).
Note: Even in GMIME_RFC_COMPLIANCE_STRICT mode, the address parser is fairly liberal in what it accepts. Setting it to GMIME_RFC_COMPLIANCE_LOOSE just makes it try harder to deal with garbage input.
gboolean
g_mime_parser_options_get_allow_addresses_without_domain
(GMimeParserOptions *options);
Gets whether or not the rfc822 address parser should allow addresses without a domain.
The default is TRUE, allowing local UNIX mailbox addresses.
This option exists in order to allow parsing of mailbox addresses that do not have a domain component. These types of addresses are rare and were typically only used when sending mail to other users on the same UNIX system.
void g_mime_parser_options_set_allow_addresses_without_domain (GMimeParserOptions *options,gboolean allow);
Sets whether the rfc822 address parser should allow addresses without a domain.
The default is TRUE, allowing local UNIX mailbox addresses.
This option exists in order to allow parsing of mailbox addresses that do not have a domain component. These types of addresses are rare and were typically only used when sending mail to other users on the same UNIX system.
gboolean
g_mime_parser_options_get_allow_unquoted_commas_in_addresses
(GMimeParserOptions *options);
Gets whether unquoted commas are allowed in address display names.
The default is TRUE, matching MimeKit's address recovery behavior.
void g_mime_parser_options_set_allow_unquoted_commas_in_addresses (GMimeParserOptions *options,gboolean allow);
Sets whether unquoted commas are allowed in address display names. A comma following a quoted word is still treated as an address separator. This option is independent of whether domainless addresses are allowed.
gboolean
g_mime_parser_options_get_respect_content_length
(GMimeParserOptions *options);
Gets whether Content-Length headers postpone recognition of mbox
From-lines until the declared body length has been consumed.
The default is FALSE. Other input formats ignore this option.
void g_mime_parser_options_set_respect_content_length (GMimeParserOptions *options,gboolean respect);
Enables Content-Length handling for mbox input. The first header with a valid nonnegative 32-bit numeric prefix is used; invalid values are ignored. The raw value must start with whitespace followed by decimal digits. This does not truncate content at the declared length: the parser resumes looking for a From-line there.
gboolean
g_mime_parser_options_get_detect_openpgp
(GMimeParserOptions *options);
Gets whether parsing scans leaf content for inline OpenPGP armor markers.
The default is FALSE. This does not affect explicit OpenPGP detection
through g_mime_part_get_openpgp_data() or GMimeFilterOpenPGP.
void g_mime_parser_options_set_detect_openpgp (GMimeParserOptions *options,gboolean detect);
Enables GMime's optional inline OpenPGP detection extension. This scans
the original transfer-encoded content, not decoded Base64 or uuencoded
bytes. g_mime_part_get_openpgp_data() can still detect decoded content
on demand when parsing has not cached a result.
int
g_mime_parser_options_get_max_header_length
(GMimeParserOptions *options);
Gets the maximum raw length of a single header, in bytes. The default is 32768 (32 KiB).
void g_mime_parser_options_set_max_header_length (GMimeParserOptions *options,int max_length);
Sets the maximum length of a single header. The length includes the field
name, colon, raw value, folding whitespace and terminating newline sequence.
GMimeParser fails with GMIME_ERROR_HEADER_TOO_LONG before buffering data
beyond this limit.
GMimeRfcComplianceMode
g_mime_parser_options_get_parameter_compliance_mode
(GMimeParserOptions *options);
Gets the compliance mode that should be used when parsing Content-Type and Content-Disposition parameters.
Note: Even in GMIME_RFC_COMPLIANCE_STRICT mode, the parameter parser is fairly liberal in what it accepts. Setting it to GMIME_RFC_COMPLIANCE_LOOSE just makes it try harder to deal with garbage input.
void g_mime_parser_options_set_parameter_compliance_mode (GMimeParserOptions *options,GMimeRfcComplianceMode mode);
Sets the compliance mode that should be used when parsing Content-Type and Content-Disposition parameters.
In general, you'll probably want this value to be GMIME_RFC_COMPLIANCE_LOOSE (the default) as it allows maximum interoperability with existing (broken) mail clients and other mail software such as sloppily written perl scripts (aka spambots).
Note: Even in GMIME_RFC_COMPLIANCE_STRICT mode, the parameter parser is fairly liberal in what it accepts. Setting it to GMIME_RFC_COMPLIANCE_LOOSE just makes it try harder to deal with garbage input.
GMimeRfcComplianceMode
g_mime_parser_options_get_rfc2047_compliance_mode
(GMimeParserOptions *options);
Gets the compliance mode that should be used when parsing rfc2047 encoded words.
Note: Even in GMIME_RFC_COMPLIANCE_STRICT mode, the rfc2047 parser is fairly liberal in what it accepts. Setting it to GMIME_RFC_COMPLIANCE_LOOSE just makes it try harder to deal with garbage input.
void g_mime_parser_options_set_rfc2047_compliance_mode (GMimeParserOptions *options,GMimeRfcComplianceMode mode);
Sets the compliance mode that should be used when parsing rfc2047 encoded words.
In general, you'll probably want this value to be GMIME_RFC_COMPLIANCE_LOOSE (the default) as it allows maximum interoperability with existing (broken) mail clients and other mail software such as sloppily written perl scripts (aka spambots).
Note: Even in GMIME_RFC_COMPLIANCE_STRICT mode, the parameter parser is fairly liberal in what it accepts. Setting it to GMIME_RFC_COMPLIANCE_LOOSE just makes it try harder to deal with garbage input.
const char *
g_mime_parser_options_get_charset_encoding
(GMimeParserOptions *options);
Gets the fallback charset encoding used when decoding undeclared 8-bit header text. The default is "utf-8". UTF-8 is always attempted first, followed by this charset, and finally ISO-8859-1.
gboolean g_mime_parser_options_set_charset_encoding (GMimeParserOptions *options,const char *charset,GError **error);
Sets the fallback charset encoding for undeclared 8-bit header text, following MimeKit's CharsetEncoding option. The name is copied and must be supported by the platform's iconv implementation.
UTF-8 is always attempted first and ISO-8859-1 last. An unsupported or empty name fails without changing the option.
options |
||
charset |
charset encoding name, or |
[nullable] |
error |
return location for a GError, or |
GMimeParserWarningFunc
g_mime_parser_options_get_warning_callback
(GMimeParserOptions *options);
Gets callback function which is called if the parser detects any issues.
[skip]
void g_mime_parser_options_set_warning_callback (GMimeParserOptions *options,GMimeParserWarningFunc warning_cb,gpointer user_data,GDestroyNotify notify);
Registers the callback function being called if the parser detects any issues.
New applications should prefer g_mime_parser_set_compliance_logger() or
g_mime_reader_set_compliance_logger(). Warning callbacks remain supported
for diagnostics outside the compliance APIs' coverage; see GMimeParserWarning.
options |
||
warning_cb |
a GMimeParserWarningFunc or |
|
user_data |
data passed to the warning callback function |
|
notify |
callback function ran on destruction |
typedef struct _GMimeParserOptions GMimeParserOptions;
A reference-counted set of parser options used by GMimeParser and various
other parsing functions. Boxed copies share settings; use
g_mime_parser_options_clone() for an independent copy.
An RFC compliance mode.
Issues the GMimeParser detects. Note that the GMIME_CRIT_* issues indicate that some parts of the GMimeParser input may
be ignored or will be interpreted differently by other software products.
New applications should prefer the GMimeComplianceViolation reporting APIs.
Register a logger with g_mime_parser_set_compliance_logger() or
g_mime_reader_set_compliance_logger() to receive structured
GMimeComplianceIssue diagnostics with more detailed input positions.
The two reporting mechanisms have different coverage. Parser warning callbacks remain supported for diagnostics not currently provided by the compliance APIs, including value-conflict distinctions and decoder warnings outside the selected encoded-word validator headers. They are not deprecated and may be used alongside compliance reporting; installing a compliance logger does not replace or disable a parser warning callback.
|
Repeated exactly the same header which should exist only once. |
||
|
Repeated exactly the same header parameter. |
||
|
A header contains unencoded 8-bit characters. |
||
|
Invalid content type, assuming |
||
|
Invalid RFC 2047 encoded header value. |
||
|
No child parts detected within a multipart. |
||
|
The message is truncated. |
||
|
A message was returned after EOF was encountered where a nested entity's headers should start or before its field name was complete. |
||
|
Invalid header name, the parser may skip the message or parts of it. |
||
|
Conflicting header. |
||
|
Conflicting header parameter. |
||
|
A multipart lacks the required boundary parameter. |
||
|
Invalid header parameter. |
||
|
Invalid address list. |
||
|
The maximum MIME nesting level has been exceeded. This is very likely to be an attempt to exploit the MIME parser. |
||
|
A MIME part's headers were terminated by a boundary marker. |
||
|
A MIME part was encountered without any headers -or- content. This is very likely to be an attempt to exploit the MIME parser. |