MIME compliance

MIME compliance — Optional diagnostic reporting for MIME readers

Functions

Types and Values

Description

Compliance findings describe the original wire bytes without changing parsing or decoding. Transport and storage contexts affect severity only. Reader operations snapshot their options and reset per-violation budgets.

Functions

GMimeComplianceIssueFunc ()

void
(*GMimeComplianceIssueFunc) (const GMimeComplianceIssue *issue,
                             gpointer user_data);

Receives a compliance finding without changing how MIME data is parsed.

Parameters

issue

the diagnostic, borrowed during the callback.

[transfer none]

user_data

application data

 

g_mime_compliance_options_new ()

GMimeComplianceOptions *
g_mime_compliance_options_new (void);

Enables all validators in transport context, without a reporting limit.

Returns

new compliance options with one reference.

[transfer full]


g_mime_compliance_options_get_default ()

GMimeComplianceOptions *
g_mime_compliance_options_get_default (void);

Gets application-wide defaults. Configure these once at startup, before creating readers; concurrent mutation is not supported.

The returned reference belongs to GMime. Use g_mime_compliance_options_ref() to retain it independently, or g_mime_compliance_options_clone() for a copy.

Returns

the shared default options.

[transfer none]


g_mime_compliance_options_clone ()

GMimeComplianceOptions *
g_mime_compliance_options_clone (GMimeComplianceOptions *options);

Copies the settings independently. Unlike g_mime_compliance_options_ref() or g_boxed_copy(), this does not share settings.

Parameters

options

options to copy, or NULL for defaults.

[nullable]

Returns

an independent copy.

[transfer full]


g_mime_compliance_options_ref ()

GMimeComplianceOptions *
g_mime_compliance_options_ref (GMimeComplianceOptions *options);

Atomically acquires a reference to options . This shares the same settings; concurrent changes to the settings still require external synchronization.

Parameters

options

a GMimeComplianceOptions

 

Returns

options with an additional reference.

[transfer full]


g_mime_compliance_options_unref ()

void
g_mime_compliance_options_unref (GMimeComplianceOptions *options);

Atomically releases a reference to options . The options are destroyed when the last reference is released.

Parameters


g_mime_compliance_options_get_context ()

GMimeComplianceContext
g_mime_compliance_options_get_context (GMimeComplianceOptions *options);

Parameters

options

compliance options

 

Returns

the context used to classify diagnostic severity.


g_mime_compliance_options_set_context ()

void
g_mime_compliance_options_set_context (GMimeComplianceOptions *options,
                                       GMimeComplianceContext context);

Sets severity context without affecting which defects are detected.

Parameters

options

compliance options

 

context

transport or storage context

 

g_mime_compliance_options_get_enabled_validators ()

GMimeComplianceValidators
g_mime_compliance_options_get_enabled_validators
                               (GMimeComplianceOptions *options);

Parameters

options

compliance options

 

Returns

flags selecting additional address and encoding validators.


g_mime_compliance_options_set_enabled_validators ()

void
g_mime_compliance_options_set_enabled_validators
                               (GMimeComplianceOptions *options,
                                GMimeComplianceValidators validators);

Selects specialized validators. General wire and structure checks remain enabled when a reader has a compliance logger.

Parameters

options

compliance options

 

validators

specialized validators to enable

 

g_mime_compliance_options_get_max_issues_per_violation ()

guint
g_mime_compliance_options_get_max_issues_per_violation
                               (GMimeComplianceOptions *options);

Parameters

options

compliance options

 

Returns

the per-violation budget, or zero for unlimited reporting.


g_mime_compliance_options_set_max_issues_per_violation ()

void
g_mime_compliance_options_set_max_issues_per_violation
                               (GMimeComplianceOptions *options,
                                guint limit);

Limits reporting independently for each violation in a reader operation. The first suppressed finding produces one TOO_MANY_COMPLIANCE_ISSUES marker; other violations still have their own budgets.

Parameters

options

compliance options

 

limit

maximum occurrences of each violation, or zero for unlimited

 

g_mime_compliance_issue_new ()

GMimeComplianceIssue *
g_mime_compliance_issue_new (GMimeComplianceContext context,
                             GMimeComplianceViolation violation,
                             gint64 stream_offset,
                             guint64 line_number,
                             guint64 column_number,
                             GMimeCompliancePositionKind position_kind);

Parameters

context

transport or storage context

 

violation

a diagnostic identity, excluding NONE

 

stream_offset

absolute input offset

 

line_number

1-based line number

 

column_number

1-based column, or 0 if unknown

 

position_kind

what the reported position identifies

 

Returns

a new diagnostic.

[transfer full]


g_mime_compliance_issue_copy ()

GMimeComplianceIssue *
g_mime_compliance_issue_copy (const GMimeComplianceIssue *issue);

Parameters

issue

the diagnostic to copy

 

Returns

an independent diagnostic.

[transfer full]


g_mime_compliance_issue_free ()

void
g_mime_compliance_issue_free (GMimeComplianceIssue *issue);

Releases a diagnostic.

Parameters

issue

diagnostic to release.

[nullable]

g_mime_compliance_issue_equal ()

gboolean
g_mime_compliance_issue_equal (const GMimeComplianceIssue *a,
                               const GMimeComplianceIssue *b);

Parameters

a

the first diagnostic

 

b

the second diagnostic

 

Returns

TRUE if context, violation and every position field are equal.


g_mime_compliance_issue_to_string ()

char *
g_mime_compliance_issue_to_string (const GMimeComplianceIssue *issue);

Parameters

issue

the diagnostic

 

Returns

its identity and input position.

[transfer full]


g_mime_compliance_violation_get_severity ()

GMimeComplianceSeverity
g_mime_compliance_violation_get_severity
                               (GMimeComplianceViolation violation,
                                GMimeComplianceContext context);

Parameters

violation

a diagnostic identity, excluding NONE

 

context

transport or storage context

 

Returns

severity of this violation in context .


g_mime_compliance_violation_get_categories ()

GMimeComplianceCategories
g_mime_compliance_violation_get_categories
                               (GMimeComplianceViolation violation);

Parameters

violation

a diagnostic identity, excluding NONE

 

Returns

flags describing the possible consequences.


g_mime_compliance_violation_get_name ()

const char *
g_mime_compliance_violation_get_name (GMimeComplianceViolation violation);

Parameters

violation

a diagnostic identity, excluding NONE

 

Returns

the static diagnostic name, matching MimeKit.

[transfer none]


g_mime_compliance_violation_get_description ()

const char *
g_mime_compliance_violation_get_description
                               (GMimeComplianceViolation violation);

Parameters

violation

a diagnostic identity, excluding NONE

 

Returns

the static English description.

[transfer none]


g_mime_compliance_violation_get_remarks ()

const char *
g_mime_compliance_violation_get_remarks
                               (GMimeComplianceViolation violation);

Parameters

violation

a diagnostic identity, excluding NONE

 

Returns

static English explanatory remarks.

[transfer none]

Types and Values

enum GMimeComplianceContext

Context used to determine a finding's severity, not its detection.

Members

GMIME_COMPLIANCE_CONTEXT_TRANSPORT

validate mail being transported

 

GMIME_COMPLIANCE_CONTEXT_STORAGE

validate stored mail

 

enum GMimeComplianceSeverity

The severity of a diagnostic in its reporting context.

Members

GMIME_COMPLIANCE_SEVERITY_MINOR

a minor conformance defect

 

GMIME_COMPLIANCE_SEVERITY_MAJOR

a significant interoperability defect

 

GMIME_COMPLIANCE_SEVERITY_CRITICAL

a potentially dangerous defect

 

enum GMimeComplianceCategories

Flags describing the possible consequences of a violation.

Members

GMIME_COMPLIANCE_CATEGORY_NONE

no category

 

GMIME_COMPLIANCE_CATEGORY_INTEROPERABILITY

interoperability concerns

 

GMIME_COMPLIANCE_CATEGORY_DATA_LOSS

potential loss or alteration of data

 

GMIME_COMPLIANCE_CATEGORY_SECURITY

security concerns

 

enum GMimeComplianceValidators

General header, structure and content checks remain enabled whenever a logger is installed. These flags select additional grammar validators.

Members

GMIME_COMPLIANCE_VALIDATOR_NONE

disable specialized validators

 

GMIME_COMPLIANCE_VALIDATOR_BASE64

validate base64 wire content

 

GMIME_COMPLIANCE_VALIDATOR_QUOTED_PRINTABLE

validate quoted-printable content

 

GMIME_COMPLIANCE_VALIDATOR_UUENCODE

validate uuencoded content

 

GMIME_COMPLIANCE_VALIDATOR_ADDRESS

validate address header grammar

 

GMIME_COMPLIANCE_VALIDATOR_PARAMETERS

validate malformed or repeated parameters, RFC 2047 encoded-words, malformed RFC 2231 encoded values, and missing continuation segments in Content-Type and Content-Disposition

 

GMIME_COMPLIANCE_VALIDATOR_ENCODED_WORDS

validate RFC 2047 syntax in address headers, Subject, Comments, Content-Description and X- headers, including address placement; independent of address syntax and parameter validation

 

GMIME_COMPLIANCE_VALIDATOR_ALL

enable all specialized validators

 

enum GMimeCompliancePositionKind

Interpretation of a diagnostic's input position.

Members

GMIME_COMPLIANCE_POSITION_EXACT

exact offending byte or end position

 

GMIME_COMPLIANCE_POSITION_LINE_START

beginning of the affected line

 

GMIME_COMPLIANCE_POSITION_ELEMENT_START

beginning of the affected element

 

enum GMimeComplianceViolation

Use the violation metadata functions for names, descriptions, remarks and context-specific severity.

Members

GMIME_COMPLIANCE_NONE

no violation; not a diagnostic identity

 

GMIME_COMPLIANCE_BARE_CARRIAGE_RETURN_IN_HEADER

bare CR in a header

 

GMIME_COMPLIANCE_BARE_LINEFEED_IN_HEADER

bare LF in a header

 

GMIME_COMPLIANCE_BARE_LINEFEED_IN_BODY

bare LF in a body

 

GMIME_COMPLIANCE_OVERSIZED_LINE

physical line exceeds 1000 bytes

 

GMIME_COMPLIANCE_UNEXPECTED_8BIT_BYTES_IN_HEADER

invalid UTF-8 header bytes, at the exact stream offset and byte column of the first malformed sequence's leading byte, including missing or invalid continuation bytes

 

GMIME_COMPLIANCE_UNEXPECTED_8BIT_BYTES_IN_BODY

non-ASCII bytes in 7-bit content

 

GMIME_COMPLIANCE_UNEXPECTED_NULL_BYTES_IN_HEADER

first NUL in each header, at its exact stream offset and byte column

 

GMIME_COMPLIANCE_UNEXPECTED_NULL_BYTES_IN_BODY

NUL in nonbinary content

 

GMIME_COMPLIANCE_INVALID_HEADER

invalid header syntax

 

GMIME_COMPLIANCE_INCOMPLETE_HEADER

unterminated header at EOF

 

GMIME_COMPLIANCE_BLANK_HEADER_CONTINUATION_LINE

whitespace-only continuation

 

GMIME_COMPLIANCE_REPEATED_CONTENT_TYPE

duplicate Content-Type

 

GMIME_COMPLIANCE_REPEATED_CONTENT_DISPOSITION

duplicate Content-Disposition

 

GMIME_COMPLIANCE_REPEATED_CONTENT_ID

additional Content-Id within one entity, including identical or invalid values; identifiers are not compared across entities

 

GMIME_COMPLIANCE_REPEATED_CONTENT_TRANSFER_ENCODING

duplicate transfer encoding

 

GMIME_COMPLIANCE_REPEATED_DATE

duplicate Date

 

GMIME_COMPLIANCE_REPEATED_FROM

duplicate From

 

GMIME_COMPLIANCE_REPEATED_SENDER

duplicate Sender

 

GMIME_COMPLIANCE_REPEATED_REPLY_TO

duplicate Reply-To

 

GMIME_COMPLIANCE_REPEATED_TO

duplicate To

 

GMIME_COMPLIANCE_REPEATED_CC

duplicate Cc

 

GMIME_COMPLIANCE_REPEATED_BCC

duplicate Bcc

 

GMIME_COMPLIANCE_REPEATED_MESSAGE_ID

duplicate Message-Id

 

GMIME_COMPLIANCE_REPEATED_IN_REPLY_TO

duplicate In-Reply-To

 

GMIME_COMPLIANCE_REPEATED_REFERENCES

duplicate References

 

GMIME_COMPLIANCE_REPEATED_SUBJECT

duplicate Subject

 

GMIME_COMPLIANCE_REPEATED_RETURN_PATH

duplicate Return-Path

 

GMIME_COMPLIANCE_REPEATED_RESENT_DATE

duplicate Resent-Date within a block

 

GMIME_COMPLIANCE_REPEATED_RESENT_FROM

duplicate Resent-From within a block

 

GMIME_COMPLIANCE_REPEATED_RESENT_SENDER

duplicate Resent-Sender within a block

 

GMIME_COMPLIANCE_REPEATED_RESENT_TO

duplicate Resent-To within a block

 

GMIME_COMPLIANCE_REPEATED_RESENT_CC

duplicate Resent-Cc within a block

 

GMIME_COMPLIANCE_REPEATED_RESENT_BCC

duplicate Resent-Bcc within a block

 

GMIME_COMPLIANCE_REPEATED_RESENT_MESSAGE_ID

duplicate Resent-Message-Id within a block

 

GMIME_COMPLIANCE_MISSING_DATE

missing message Date

 

GMIME_COMPLIANCE_MISSING_FROM

missing message From

 

GMIME_COMPLIANCE_MISSING_MESSAGE_ID

missing message Message-Id

 

GMIME_COMPLIANCE_MISSING_MIME_VERSION

MIME headers without MIME-Version

 

GMIME_COMPLIANCE_INVALID_CONTENT_TYPE

malformed media type, including unexpected text after type/subtype and before any parameter separator

 

GMIME_COMPLIANCE_INVALID_CONTENT_TRANSFER_ENCODING

unrecognized transfer encoding

 

GMIME_COMPLIANCE_ILLEGAL_MESSAGE_RFC822_CONTENT_TRANSFER_ENCODING

encoded message container

 

GMIME_COMPLIANCE_ILLEGAL_MULTIPART_CONTENT_TRANSFER_ENCODING

illegal multipart encoding

 

GMIME_COMPLIANCE_MISSING_MULTIPART_BOUNDARY_PARAMETER

missing boundary parameter

 

GMIME_COMPLIANCE_INVALID_MULTIPART_BOUNDARY_PARAMETER

nonconforming boundary value

 

GMIME_COMPLIANCE_INVALID_PARAMETER

malformed parameter declaration or fragment, reported at its element start; encoded RFC 2231 value contents are not validated

 

GMIME_COMPLIANCE_INVALID_RFC2231_PARAMETER

malformed RFC 2231 encoded value, reported at the declaration's element start without validating charsets or decoded characters

 

GMIME_COMPLIANCE_ENCODED_WORD_IN_PARAMETER

RFC 2047 encoded-word syntax in a parameter, reported once per declaration at its element start without decoding

 

GMIME_COMPLIANCE_REPEATED_BOUNDARY_PARAMETER

competing boundary declarations or repeated continuation indices

 

GMIME_COMPLIANCE_REPEATED_FILENAME_PARAMETER

repeated name/filename declarations, allowing one ordinary fallback

 

GMIME_COMPLIANCE_REPEATED_PARAMETER

repeated declarations of another MIME parameter

 

GMIME_COMPLIANCE_MISSING_PARAMETER_SEGMENT

missing RFC 2231 continuation segments, reported at the first continuation declaration

 

GMIME_COMPLIANCE_INVALID_ENCODED_WORD

malformed RFC 2047 encoded-word syntax, reported at the candidate's element start without charset lookup or decoding

 

GMIME_COMPLIANCE_INVALID_ENCODED_WORD_PLACEMENT

complete encoded-word envelope in a quoted string or addr-spec, reported at the candidate's element start

 

GMIME_COMPLIANCE_EXCESSIVE_ANGLE_BRACKETS_IN_ADDRESS

excess address brackets

 

GMIME_COMPLIANCE_UNBALANCED_ANGLE_BRACKETS_IN_ADDRESS

unmatched address brackets

 

GMIME_COMPLIANCE_UNBALANCED_QUOTES_IN_ADDRESS

unmatched address quotes

 

GMIME_COMPLIANCE_UNBALANCED_PARENTHESES_IN_ADDRESS

unmatched address comment

 

GMIME_COMPLIANCE_UNQUOTED_DISPLAY_NAME

display name requires quoting

 

GMIME_COMPLIANCE_ADDRESS_IN_DISPLAY_NAME

address embedded in a display name

 

GMIME_COMPLIANCE_UNQUOTED_ADDRESS_IN_DISPLAY_NAME

unquoted address in a display name

 

GMIME_COMPLIANCE_ADDRESS_IN_GROUP_DISPLAY_NAME

address in a group name

 

GMIME_COMPLIANCE_UNQUOTED_ADDRESS_IN_GROUP_DISPLAY_NAME

unquoted address in a group name

 

GMIME_COMPLIANCE_INVALID_LOCAL_PART

invalid mailbox local part

 

GMIME_COMPLIANCE_MISSING_ADDRESS_SEPARATOR

missing address-list separator

 

GMIME_COMPLIANCE_AMBIGUOUS_MAILBOX_BOUNDARY

ambiguous mailbox separation

 

GMIME_COMPLIANCE_EXTRANEOUS_COMMA_IN_ADDRESS_LIST

extra address-list comma

 

GMIME_COMPLIANCE_OBSOLETE_ROUTE_ADDRESS

obsolete source-route syntax

 

GMIME_COMPLIANCE_ADDRESS_WITHOUT_DOMAIN

domainless address

 

GMIME_COMPLIANCE_OBSOLETE_DOMAIN_SYNTAX

obsolete domain spelling

 

GMIME_COMPLIANCE_INVALID_DOMAIN

invalid address domain

 

GMIME_COMPLIANCE_TRAILING_DOT_IN_DOMAIN

trailing domain dot

 

GMIME_COMPLIANCE_WHITESPACE_IN_DOMAIN_LITERAL

whitespace in a domain literal

 

GMIME_COMPLIANCE_INVALID_CHARACTER_IN_DOMAIN_LITERAL

invalid domain-literal byte

 

GMIME_COMPLIANCE_INVALID_8BIT_ADDRESS

invalid non-ASCII address bytes

 

GMIME_COMPLIANCE_MISSING_GROUP_TERMINATOR

missing group semicolon

 

GMIME_COMPLIANCE_NON_CONFORMANT_ADDRESS

other nonconforming address syntax

 

GMIME_COMPLIANCE_NULL_BYTE_IN_ADDRESS

NUL in an address

 

GMIME_COMPLIANCE_NULL_BYTE_IN_DISPLAY_NAME

NUL in a display name

 

GMIME_COMPLIANCE_LINE_BREAK_IN_ADDRESS

illegal address line break

 

GMIME_COMPLIANCE_CONTROL_CHARACTER_IN_ADDRESS

illegal address control byte

 

GMIME_COMPLIANCE_ISO2022_SEQUENCE_IN_LOCAL_PART

ISO-2022 local-part escape

 

GMIME_COMPLIANCE_EMPTY_GROUP_NAME

unnamed address group

 

GMIME_COMPLIANCE_NESTED_ADDRESS_GROUP

group nested inside another group

 

GMIME_COMPLIANCE_MISSING_BODY_SEPARATOR

missing header/body separator

 

GMIME_COMPLIANCE_MISSING_MULTIPART_BOUNDARY

enclosing boundary encountered before the multipart closing delimiter

 

GMIME_COMPLIANCE_MIME_DEPTH_LIMIT_EXCEEDED

container flattened at the depth limit

 

GMIME_COMPLIANCE_INCOMPLETE_BASE64_QUANTUM

incomplete base64 quantum

 

GMIME_COMPLIANCE_INVALID_BASE64_CHARACTER

invalid base64 byte

 

GMIME_COMPLIANCE_INVALID_BASE64_PADDING

invalid base64 padding, including nonzero unused bits before padding, reported at the first '='

 

GMIME_COMPLIANCE_BASE64_CHARACTERS_AFTER_PADDING

base64 data after padding

 

GMIME_COMPLIANCE_OBSOLETE_BASE64_COMMENT

obsolete base64 comment

 

GMIME_COMPLIANCE_INVALID_QUOTED_PRINTABLE_ENCODING

malformed quoted-printable escape

 

GMIME_COMPLIANCE_INVALID_QUOTED_PRINTABLE_SOFT_BREAK

malformed soft line break

 

GMIME_COMPLIANCE_INVALID_UUENCODE_PRETEXT

invalid uuencode preamble

 

GMIME_COMPLIANCE_INVALID_UUENCODE_FILE_MODE

invalid uuencode file permissions

 

GMIME_COMPLIANCE_INVALID_UUENCODED_CONTENT

invalid uuencoded byte

 

GMIME_COMPLIANCE_INVALID_UUENCODED_LINE_LENGTH

invalid encoded line length

 

GMIME_COMPLIANCE_INCOMPLETE_UUENCODED_LINE

truncated encoded line

 

GMIME_COMPLIANCE_INVALID_UUENCODED_LINE_EXTRA_DATA

extra encoded line data

 

GMIME_COMPLIANCE_INVALID_UUENCODE_END_MARKER

malformed uuencode end marker

 

GMIME_COMPLIANCE_INCOMPLETE_UUENCODED_CONTENT

missing uuencode terminator

 

GMIME_COMPLIANCE_MESSAGE_TRUNCATED

stream ended before the multipart closing delimiter

 

GMIME_COMPLIANCE_EOF_BEFORE_BODY_SEPARATOR

stream ended while waiting for another header or the empty line terminating the header block

 

GMIME_COMPLIANCE_AMBIGUOUS_MULTIPART_BOUNDARY

a delimiter line matches more than one active multipart; reported at its first hyphen

 

GMIME_COMPLIANCE_TOO_MANY_COMPLIANCE_ISSUES

reporting budget was exceeded

 

GMimeComplianceIssue

typedef struct {
	GMimeComplianceContext context;
	GMimeComplianceViolation violation;
	gint64 stream_offset;
	guint64 line_number;
	guint64 column_number;
	GMimeCompliancePositionKind position_kind;
} GMimeComplianceIssue;

A boxed diagnostic referring to the original wire bytes.

Members

GMimeComplianceContext context;

reporting context

 

GMimeComplianceViolation violation;

diagnostic identity

 

gint64 stream_offset;

absolute input byte offset

 

guint64 line_number;

1-based physical line number

 

guint64 column_number;

1-based byte column, or zero if unknown

 

GMimeCompliancePositionKind position_kind;

interpretation of the input position

 

GMimeComplianceOptions

typedef struct _GMimeComplianceOptions GMimeComplianceOptions;

Reference-counted boxed diagnostic options. References and boxed copies share settings; explicit clones and internal snapshots remain independent. Reader operations snapshot these values; changing them never changes the parsing policy.