/** * Reply attribution detection. * * Two shapes are handled, and the difference matters: * * 1. A single attribution line: "On Mon, 13 Jan 2025 at 09:15, Bob wrote:". One line, strong. * 2. An embedded copy of the previous message's headers, which Outlook and several webmail * clients emit as consecutive From/Sent/To/Subject lines. * * The second shape needs care. A single "From:" line is not evidence of anything, because ordinary * prose starts that way often enough to matter. Only a run of consecutive field lines including a * date-like or subject field counts, and even then the strength is capped below the single line * attribution, because a person pasting an address block looks identical. */ import { type Evidence } from '../segment/types'; export interface ReplyHeaderMatch { /** First line index of the anchor, inclusive. */ startLine: number; /** Last line index of the anchor, inclusive. */ endLine: number; evidence: Evidence; } /** * Detect a single line attribution. * * Lines longer than 300 characters are rejected: a genuine attribution line is short, and a long * one is almost always a paragraph that happens to end in "wrote:". */ export declare function detectAttributionLine(line: string): Evidence | null; /** * A sentence announcing that the reply is written into the quoted text: "my answers are inline", * "Answers are in your letter". Evidence only; the rules decide what it changes, and only for * authored text above the history. Lines are bounded like attribution lines so a hostile * single-line body stays cheap. */ export declare function detectInlineAnnouncement(lines: readonly string[]): Evidence | null; /** * Detect an embedded header block starting at or after `from`. * * Returns the first match found, scanning forward. The caller supplies de-prefixed line content so * that a header block inside a quote is detected the same way as one outside it. * * Single pass, deliberately. The obvious implementation restarts an inner forward scan at every * candidate line, which is quadratic: 12,000 consecutive `Cc:` lines never form a strong block but * make the inner scan traverse almost the whole remaining input from every outer position, and * measured at 4.8 seconds of blocked event loop on that input. Inbound mail is attacker controlled, * so that is a denial of service, not a slow path. * * The single pass is exactly equivalent, not an approximation. Lines partition into *chains*: * maximal runs of header-shaped lines joined by blank gaps of at most `MAX_GAP`, terminated by any * other line or by a longer blank run. The set of roles collected from a start inside a chain is a * subset of the set collected from the chain's own start, and strength is monotone under superset, * so if the chain start is not strong no later start in that chain can be, and if it is strong it * is also the earliest strong start. Checking each chain once therefore returns the same match the * restarting scan did. */ export declare function detectQuotedHeaderBlock(lines: readonly string[], from?: number): ReplyHeaderMatch | null; /** * Detect the Outlook style horizontal rule, a long run of underscores on its own line. * * Weak on its own. It is only meaningful when an embedded header block follows within a few lines, * which the segmenter checks. */ export declare function detectRuleSeparator(line: string): Evidence | null; //# sourceMappingURL=reply-header.d.ts.map