Table of Contents

Interface IAttachmentTextExtractor

Namespace
MailFathom.Application.Emails.Extraction.Attachments
Assembly
MailFathom.Application.dll

Reads one attachment's plain text, or says exactly why it read none.

public interface IAttachmentTextExtractor

Remarks

The port exists so that the document parsers stay inside their adapter. No parser type and no third-party document model crosses it: what comes back is characters and a closed set of reasons, and a caller never interprets an exception a parser raised.

It is handed an attachment already opened from stored content, so extraction reaches no mail server and no network and cannot affect a remote \Seen flag. The opened attachment stays the caller's to dispose; an implementation reads it and owns nothing.

Reading an attachment is the largest attack surface this system has, so an implementation never runs it inside a synchronization transaction, where a hostile document would stall a checkpoint and hold a database transaction open for as long as it took. It does run on paths a caller waits on: a message being screened before it is sent or saved as a draft, and an attachment being screened before it is streamed to whoever asked for it. Both are acts that must be judged on the whole of what would leave, and neither can be answered later. What bounds the delay a caller pays there is AttachmentTextExtractionOptions, which every implementation applies per attachment, beside EmailAttachmentTextBounds, which such a caller applies across the message so that one message costs the same whichever path met it. Nothing an implementation reads is written to the file system, and nothing a document declares as a macro, a script, an embedded object, or any other active content is executed, evaluated, or handed to anything that would.

One of those bounds does not hold on a single unit of work, and a caller-waited path is where that matters. Timeout is observed between units — a page, an archive part, an element — because no parser here takes a cancellation token, so a PDF whose one page inflates enormously is bounded by MaxInputOctets on the octets that arrived and by nothing else. On a synchronization stage that costs a worker; on a send being screened or an attachment being served it costs the caller, on a request nothing here will cut short. It is recorded rather than defended, and issue #1684 is where the gap is tracked.

An attachment an antivirus pass has judged infected is not excluded here, because no such pass exists yet. When one lands, this is the port it gates: an infected attachment is skipped before a parser is offered its bytes.

Methods

ExtractTextAsync(IOpenedEmailAttachment, CancellationToken)

Reads the text of one opened attachment.