while I know that mbox is loosely defined when it comes to escaping
lines that begin with "From", there seems to be disagreement between
smtpd (which seems to do the "right"ish thing) and mail(1)

# Reproducing

  $ echo From me > original.txt
  $ mail -s yep $USER < original.txt

smtpd receives and delivers this as expected, escaping the /^From/ per
the common spec/convention by prefixing it with a ">":

  $ tail -3 /var/mail/$USER

  >From me

as expected.

However, when reading the message in mail(1), it doesn't un-escape the
line (strip off the leading ">") when displaying the message (whether
with `p` or `top`) or when writing to a file.

# Actual results

  $ mail
  & p
  ...
  >From me
  & w received.txt
  & q
  $ diff -u original.txt received.txt  
  --- original.txt        Wed May 14 09:23:35 2025
  +++ received.txt        Wed May 14 09:24:56 2025
  @@ -1 +1 @@
  -From me
  +>From me

# Expected results

  $ mail
  & p
  ...
  From me
  & w received.txt
  & q
  $ diff -u original.txt received.txt  || echo same
  same

I'm not sure whether this should be changed in fio.c:readline() because
that seems to get called both when reading lines from the mailstore and
when reading lines from stdin.

This issue might also impact the `~m` tilde-escape, where reading in a
message-list might leave the ">" prefix in place.

FWIW, this is in 7.7 but I expect it would apply to any version (I see
the same symptoms on FreeBSD's mail(1) as well)

-tkc





Reply via email to