Skip to content

Commit 834aa40

Browse files
committed
fix: only strip first-line From: override, not later From: content (CM-1318)
Signed-off-by: Uroš Marolt <uros@marolt.me>
1 parent fac52d3 commit 834aa40

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

  • services/apps/mailing_list_integration/src/crowdmail/services/parse

services/apps/mailing_list_integration/src/crowdmail/services/parse/noteren.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,19 @@ def parse_email(
303303
seen_content = False
304304
# Skip quoted lines ">" and empty ones when counting lines of new content
305305
for line in iter(body.splitlines()):
306-
if not seen_content and len(line) != 0:
307-
# Only the very first non-empty line of the body may override
308-
# authorship (this is where git-format-patch / b4 put it). A
309-
# "From: " appearing later in the body is just content (e.g. a
310-
# forwarded or pasted message) and must not hijack attribution.
306+
# Only the very first non-empty line of the body may override
307+
# authorship (this is where git-format-patch / b4 put it). A
308+
# "From: " appearing later in the body is just content (e.g. a
309+
# forwarded or pasted message) and must not hijack attribution nor
310+
# be excluded from the stored body/line count.
311+
is_first_content_line = not seen_content and len(line) != 0
312+
is_from_override = is_first_content_line and line.find("From: ") == 0
313+
if is_first_content_line:
311314
seen_content = True
312-
if line.find("From: ") == 0:
315+
if is_from_override:
313316
author_name, author_email = parse_author(line)
314317

315-
if line.find(">") != 0 and line.find("On ") != 0 and line.find("From: ") != 0:
318+
if line.find(">") != 0 and line.find("On ") != 0 and not is_from_override:
316319
if len(line) != 0:
317320
num_lines += 1
318321
json_body += line

0 commit comments

Comments
 (0)