GMimeParserOptions: GMime 3.0 Reference Manual

## GMimeParserOptions GMimeParserOptions — Parser options |

## Functions

void | (*GMimeParserWarningFunc) ()
GMimeParserOptions * | g_mime_parser_options_new ()
void | g_mime_parser_options_free ()
GMimeParserOptions * | g_mime_parser_options_clone ()
GMimeParserOptions * | g_mime_parser_options_get_default ()
GMimeRfcComplianceMode | g_mime_parser_options_get_address_compliance_mode ()
void | g_mime_parser_options_set_address_compliance_mode ()
gboolean | g_mime_parser_options_get_allow_addresses_without_domain ()
void | g_mime_parser_options_set_allow_addresses_without_domain ()
GMimeRfcComplianceMode | g_mime_parser_options_get_parameter_compliance_mode ()
void | g_mime_parser_options_set_parameter_compliance_mode ()
GMimeRfcComplianceMode | g_mime_parser_options_get_rfc2047_compliance_mode ()
void | g_mime_parser_options_set_rfc2047_compliance_mode ()
const char ** | g_mime_parser_options_get_fallback_charsets ()
void | g_mime_parser_options_set_fallback_charsets ()
GMimeParserWarningFunc | g_mime_parser_options_get_warning_callback ()
void | g_mime_parser_options_set_warning_callback ()

## Types and Values

| GMimeParserOptions
enum | GMimeRfcComplianceMode
enum | GMimeParserWarning

## Description

A GMimeParserOptions is used to pass various options to GMimeParser and all of the various other parser functions in GMime.

## Functions

### GMimeParserWarningFunc ()

    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()`.

#### Parameters

offset | parser offset where the issue has been detected, or -1 if it is unknown |
errcode | a GMimeParserWarning |
item | a NUL-terminated string containing the value causing the issue, may be `NULL` |
user_data | User-supplied callback data. |

### g_mime_parser_options_new ()

    GMimeParserOptions *
    g_mime_parser_options_new (void);

Creates a new set of GMimeParserOptions.

#### Returns

a newly allocated set of GMimeParserOptions with the default values.

### g_mime_parser_options_free ()

    void
    g_mime_parser_options_free (GMimeParserOptions *options);

Frees a set of GMimeParserOptions.

#### Parameters

options | a GMimeParserOptions |

### g_mime_parser_options_clone ()

    GMimeParserOptions *
    g_mime_parser_options_clone (GMimeParserOptions *options);

Clones a GMimeParserOptions.

#### Parameters

options | a GMimeParserOptions or `NULL`. | [nullable]

#### Returns

a newly allocated GMimeParserOptions.

[transfer full]

### g_mime_parser_options_get_default ()

    GMimeParserOptions *
    g_mime_parser_options_get_default (void);

Gets the default parser options.

#### Returns

the default parser options.

### g_mime_parser_options_get_address_compliance_mode ()

    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.

#### Parameters

options | a GMimeParserOptions or `NULL`. | [nullable]

#### Returns

the compliance mode that is currently set.

### g_mime_parser_options_set_address_compliance_mode ()

    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.

#### Parameters

options | a GMimeParserOptions |
mode | a GMimeRfcComplianceMode |

### g_mime_parser_options_get_allow_addresses_without_domain ()

    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.

In general, you'll probably want this value to be `FALSE` (the default) as it allows maximum interoperability with existing (broken) mail clients and other mail software such as sloppily written perl scripts (aka spambots) that do not properly quote the name when it contains a comma.

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.

#### Parameters

options | a GMimeParserOptions or `NULL`. | [nullable]

#### Returns

`TRUE` if the address parser should allow addresses without a domain.

### g_mime_parser_options_set_allow_addresses_without_domain ()

    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.

In general, you'll probably want this value to be `FALSE` (the default) as it allows maximum interoperability with existing (broken) mail clients and other mail software such as sloppily written perl scripts (aka spambots) that do not properly quote the name when it contains a comma.

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.

#### Parameters

options | a GMimeParserOptions |
allow | `TRUE` if the parser should allow addresses without a domain or `FALSE` otherwise |

### g_mime_parser_options_get_parameter_compliance_mode ()

    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.

#### Parameters

options | a GMimeParserOptions or `NULL`. | [nullable]

#### Returns

the compliance mode that is currently set.

### g_mime_parser_options_set_parameter_compliance_mode ()

    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.

#### Parameters

options | a GMimeParserOptions |
mode | a GMimeRfcComplianceMode |

### g_mime_parser_options_get_rfc2047_compliance_mode ()

    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.

#### Parameters

options | a GMimeParserOptions or `NULL`. | [nullable]

#### Returns

the compliance mode that is currently set.

### g_mime_parser_options_set_rfc2047_compliance_mode ()

    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.

#### Parameters

options | a GMimeParserOptions |
mode | a GMimeRfcComplianceMode |

### g_mime_parser_options_get_fallback_charsets ()

    const char **
    g_mime_parser_options_get_fallback_charsets
                                   (GMimeParserOptions *options);

Gets the fallback charsets to try when decoding 8-bit headers.

#### Parameters

options | a GMimeParserOptions or `NULL`. | [nullable]

#### Returns

a `NULL`-terminated list of charsets to try when decoding 8-bit headers.

[transfer none]

### g_mime_parser_options_set_fallback_charsets ()

    void
    g_mime_parser_options_set_fallback_charsets
                                   (GMimeParserOptions *options,
                                    const char **charsets);

Sets the fallback charsets to try when decoding 8-bit headers.

Note: It is recommended that the list of charsets start with utf-8 and end with iso-8859-1.

#### Parameters

options | a GMimeParserOptions |
charsets | a `NULL`-terminated list of charsets or `NULL` for the default list |

### g_mime_parser_options_get_warning_callback ()

    GMimeParserWarningFunc
    g_mime_parser_options_get_warning_callback
                                   (GMimeParserOptions *options);

Gets callback function which is called if the parser detects any issues.

[skip]

#### Parameters

options | a GMimeParserOptions or `NULL`. | [nullable]

#### Returns

the currently registered warning callback function

### g_mime_parser_options_set_warning_callback ()

    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.

#### Parameters

options | a GMimeParserOptions |
warning_cb | a GMimeParserWarningFunc or `NULL` to clear the callback |
user_data | data passed to the warning callback function |
notify | callback function ran on destruction |

## Types and Values

### GMimeParserOptions

    typedef struct _GMimeParserOptions GMimeParserOptions;

A set of parser options used by GMimeParser and various other parsing functions.

### enum GMimeRfcComplianceMode

An RFC compliance mode.

#### Members

GMIME_RFC_COMPLIANCE_LOOSE | Attempt to be much more liberal accepting broken and/or invalid formatting. |
GMIME_RFC_COMPLIANCE_STRICT | Do not attempt to be overly liberal in accepting broken and/or invalid formatting. |

### enum GMimeParserWarning

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.

#### Members

GMIME_WARN_DUPLICATED_HEADER | Repeated exactly the same header which should exist only once. |
GMIME_WARN_DUPLICATED_PARAMETER | Repeated exactly the same header parameter. |
GMIME_WARN_UNENCODED_8BIT_HEADER | A header contains unencoded 8-bit characters. |
GMIME_WARN_INVALID_CONTENT_TYPE | Invalid content type, assuming `application/octet-stream`. |
GMIME_WARN_INVALID_RFC2047_HEADER_VALUE | Invalid RFC 2047 encoded header value. |
GMIME_WARN_MALFORMED_MULTIPART | No child parts detected within a multipart. |
GMIME_WARN_TRUNCATED_MESSAGE | The message is truncated. |
GMIME_WARN_MALFORMED_MESSAGE | The message is malformed. |
GMIME_CRIT_INVALID_HEADER_NAME | Invalid header name, the parser may skip the message or parts of it. |
GMIME_CRIT_CONFLICTING_HEADER | Conflicting header. |
GMIME_CRIT_CONFLICTING_PARAMETER | Conflicting header parameter. |
GMIME_CRIT_MULTIPART_WITHOUT_BOUNDARY | A multipart lacks the required boundary parameter. |
GMIME_WARN_INVALID_PARAMETER | Invalid header parameter. |
GMIME_WARN_INVALID_ADDRESS_LIST | Invalid address list. |
GMIME_CRIT_NESTING_OVERFLOW | The maximum MIME nesting level has been exceeded. This is very likely to be an attempt to exploit the MIME parser. |
GMIME_WARN_PART_WITHOUT_CONTENT | A MIME part's headers were terminated by a boundary marker. |
GMIME_CRIT_PART_WITHOUT_HEADERS_OR_CONTENT | A MIME part was encountered without any headers -or- content. This is very likely to be an attempt to exploit the MIME parser. |