GMimeAnonymizer

GMimeAnonymizer — Structure-preserving MIME anonymization

Functions

Types and Values

Description

Masks header values without decoding their raw bytes. Address delimiters, encoded-word charset/encoding labels, Received keywords and valid dates, content types and selected MIME parameters remain visible, matching MimeKit. Date, MIME-Version and Content-Transfer-Encoding values are preserved.

This is a diagnostic transformation, not a guarantee of removing all sensitive information. Preserved fields, dates, structural syntax, escape sequences, byte counts and whitespace can reveal information. Message and entity bodies are masked after transfer encoding, preserving their wire whitespace rather than decoding sensitive content into the output.

Functions

g_mime_anonymizer_new ()

GMimeAnonymizer *
g_mime_anonymizer_new (void);

Returns

a new anonymizer with no extra preserved fields.

[transfer full]


g_mime_anonymizer_add_preserved_header ()

gboolean
g_mime_anonymizer_add_preserved_header
                               (GMimeAnonymizer *anonymizer,
                                const char *name);

Copies name without trimming. Field matching ignores ASCII case. Adding an existing name retains its original spelling.

Parameters

anonymizer

a GMimeAnonymizer

 

name

a field name to preserve

 

Returns

whether a name was added.


g_mime_anonymizer_remove_preserved_header ()

gboolean
g_mime_anonymizer_remove_preserved_header
                               (GMimeAnonymizer *anonymizer,
                                const char *name);

Parameters

anonymizer

a GMimeAnonymizer

 

name

a field name

 

Returns

whether a name was removed, ignoring ASCII case.


g_mime_anonymizer_contains_preserved_header ()

gboolean
g_mime_anonymizer_contains_preserved_header
                               (GMimeAnonymizer *anonymizer,
                                const char *name);

Tests only the configured set, not the fields preserved by default.

Parameters

anonymizer

a GMimeAnonymizer

 

name

a field name

 

Returns

whether name is in the configured set, ignoring ASCII case.


g_mime_anonymizer_clear_preserved_headers ()

void
g_mime_anonymizer_clear_preserved_headers
                               (GMimeAnonymizer *anonymizer);

Clears the configured set without changing the default preserved fields.

Parameters

anonymizer

a GMimeAnonymizer

 

g_mime_anonymizer_get_preserved_headers ()

char **
g_mime_anonymizer_get_preserved_headers
                               (GMimeAnonymizer *anonymizer);

Returns an independent snapshot in unspecified order.

Parameters

anonymizer

a GMimeAnonymizer

 

Returns

the configured names. Free with g_strfreev().

[array zero-terminated=1][transfer full]


g_mime_anonymizer_write_headers ()

gboolean
g_mime_anonymizer_write_headers (GMimeAnonymizer *anonymizer,
                                 GMimeFormatOptions *options,
                                 GMimeHeaderList *headers,
                                 GMimeStream *stream,
                                 GError **error);

Writes every header in order, including duplicates and fields hidden by ordinary serialization options. No body separator is added. Newlines use options ; all other masking is byte-oriented, without decoding or changing the stored headers. Explicitly preserved fields still use normal formatting and newline conversion. Invalid fields are masked as unstructured bytes. Unset native placeholder headers are omitted.

Output may be partial on failure; write, formatting and flush failures are reported without closing stream or flushing after a failed write.

Parameters

anonymizer

a GMimeAnonymizer

 

options

formatting options, or NULL for the defaults.

[nullable]

headers

the headers to anonymize

 

stream

the destination stream, which is not closed

 

error

return location for an error.

[nullable]

Returns

whether all headers were written and the filtered stream flushed.


g_mime_anonymizer_write_message ()

gboolean
g_mime_anonymizer_write_message (GMimeAnonymizer *anonymizer,
                                 GMimeFormatOptions *options,
                                 GMimeMessage *message,
                                 GMimeStream *stream,
                                 GError **error);

Writes merged message/body headers and anonymizes the entire MIME tree without recursion. Raw multipart delimiters remain visible and unmodified; preambles, epilogues and transfer-encoded content are masked. Status and notification bodies use header masking, including the preservation set.

As in MimeKit, a constructed message with body headers acquires a missing MIME-Version field. Lazy status-field access may initialize content/caches. Other stored header and content bytes are not rewritten. Output may be partial on error; formatting, content I/O and destination errors propagate.

Parameters

anonymizer

a GMimeAnonymizer

 

options

formatting options, or NULL for defaults.

[nullable]

message

the message to anonymize

 

stream

the destination, which remains open

 

error

return location for an error.

[nullable]

Returns

whether anonymization succeeded.


g_mime_anonymizer_write_entity ()

gboolean
g_mime_anonymizer_write_entity (GMimeAnonymizer *anonymizer,
                                GMimeFormatOptions *options,
                                GMimeEntity *entity,
                                GMimeStream *stream,
                                GError **error);

Writes anonymized entity headers and content using the same iterative traversal as g_mime_anonymizer_write_message(). Native GMimeMessage instances are handled as messages, including merged body headers.

Parameters

anonymizer

a GMimeAnonymizer

 

options

formatting options, or NULL for defaults.

[nullable]

entity

the MIME entity to anonymize

 

stream

the destination, which remains open

 

error

return location for an error.

[nullable]

Returns

whether anonymization succeeded.

Types and Values

GMimeAnonymizer

typedef struct _GMimeAnonymizer GMimeAnonymizer;

MIME anonymization with configurable preserved header fields.