Skip to content

patch: prefer format-patch From line over email header for author - #908

Open
geliangtang wants to merge 1 commit into
sashiko-dev:mainfrom
geliangtang:main
Open

geliangtang wants to merge 1 commit into
sashiko-dev:mainfrom
geliangtang:main

Conversation

@geliangtang

Copy link
Copy Markdown

git format-patch embeds a 'From:' line as the first line of the patch body, carrying the original commit author. Use this line - not the email From header - as the authoritative author, because git send-email may rewrite the header via .mailmap while the body line preserves the original.

The parser reads the first line of the first text body part. If it starts with 'From:', it extracts 'Name '; when the name is empty or 'unknown', only the email is kept. Body parts whose first line is not a From line are ignored, leaving the existing header- based author untouched.

git format-patch embeds a 'From:' line as the first line of the patch
body, carrying the original commit author. Use this line - not the
email From header - as the authoritative author, because git
send-email may rewrite the header via .mailmap while the body line
preserves the original.

The parser reads the first line of the first text body part. If it
starts with 'From:', it extracts 'Name <email>'; when the name is
empty or 'unknown', only the email is kept. Body parts whose first
line is not a From line are ignored, leaving the existing header-
based author untouched.

Signed-off-by: Geliang Tang <geliang@kernel.org>
@sashiko-bot

sashiko-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

Sashiko review

Commit 1/1 — 93934171 patch: prefer format-patch From line over email header for author

  • [HIGH] src/patch.rs: parse_email() overwrites PatchsetMetadata.author with
    the in-body From: commit author instead of keeping the RFC 5322 From header
    sender. In a multi-patch series where a patch has a different commit author
    from the sender, its author no longer matches the cover letter's author.
    Database::message_is_cover_letter_for() and Database::create_patchset_in_tx()
    in src/db.rs then reject the patch from the series during NNTP ingestion,
    splitting it into a separate patchset row and leaving both patchsets stuck
    in Incomplete without ever running a review. This also causes
    metadata_matches_series() in src/prerequisites.rs to drop co-authored
    patches from prerequisite series.

  • [HIGH] src/patch.rs: parse_email() applies the in-body From: override to
    all messages before checking whether the message is a reply or has a diff,
    and without verifying the sender. This bypasses the is_b4_alias() check on
    X-Original-From, lets plain reply emails starting with From: spoof
    maintainer identity in score_thread_messages() in
    src/db/prior_context_queries.rs, and routes outbound review emails and
    TranscriptPrincipal::access_to_patchset() in src/access.rs to an unverified
    body address. It also hides bot senders behind the original commit author's
    address when bots forward commits with a leading From: line, bypassing
    EmailRouter::is_ignored_author() in src/main.rs and
    Reviewer::is_bot_loop_author() in src/reviewer.rs.

  • [MEDIUM] src/patch.rs: the in-body From: parser in parse_email() slices
    the header string manually without calling clean_display_name(), allowing
    control characters into PatchsetMetadata.author. It also keeps outer double
    quotes on quoted display names before calling format_mailbox(), producing
    double-escaped quotes that parse_lenient() in src/worker/email.rs leaves in
    outbound headers, uses rfind() for angle brackets where extract_email() uses
    find(), and accepts any unbracketed string containing @ as an author.

  • [MEDIUM] src/patch.rs: the in-body From: loop in parse_email() inspects
    lines().next() on the raw text part without calling
    strip_leading_mbox_from_line() and unconditionally breaks after the first
    text body part. If part 0 starts with a git format-patch From mbox
    line or a leading blank line, or if the patch lives in a later MIME part or
    attachment after an introductory text part, the From: line is missed.

  • [MEDIUM] src/patch.rs: this change adds no unit tests for parse_email()
    covering in-body From: extraction or its interaction with quoted display
    names, B4 relay aliases, and multi-patch series.

Full review and stage logs on sashiko.sashiko.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant