Re: git format-patch escaping issues in the patch format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 05, 2024 at 02:03:21AM +0100, Christoph Anton Mitterer wrote:

> On Mon, 2024-11-04 at 18:54 -0500, Jeff King wrote:
> > As you note, the mbox format is not well defined. :) The variant with
> > ">"-quoting of "From" lines is often called "mboxrd", and you can get
> > it
> > with the "--format=mboxrd" option.
> 
> But as you've said below, here too, the receiving side most likely
> doesn’t know that and then a wrong commit message would be applied
> (with no unescaping being performed or it would simply break again when
> the magic From is used).

I think there are two differences between ">From" and quote "---":

  1. There are already mbox parsers that understand and unquote ">From".
     If you know you are feeding your patches to such a parser (e.g.,
     the one in mutt) then using "mboxrd" makes sense.

  2. The consumer of the mbox format is much "closer" than the consumer
     of the "---" line.

     If you produce some patches with format-patch, you might feed them
     to your MUA or another local tool, and you know how that tool will
     unquote them. Once you email the patches, that ">From" quoting is
     irrelevant, because the receiver will get individual emails without
     the quoting. They may themselves choose to store them in an mbox,
     of course, but the details are up to them.

     Whereas the "---" line is inside the email, and will be interpreted
     on the other end by a tool like "git am". So if we introduce
     quoting in format-patch and unquoting in git-am, then correctly
     unquoting will depend on the version that the other side is using.

IMHO that is not necessarily a reason to avoid implementing quoting. If
you do accidentally put "---" in a commit message, the current outcome
is for your commit message to get silently cut off by "git am". But in a
world where we quote it and the other side is too old to unquote, then
they may end up with an extra quoting character in the result. But that
is probably a less bad outcome overall.

  There's also another flip-side mistake, which is somebody who doesn't
  quote sends to somebody who unquotes, and the result is similarly
  slightly corrupted. The mbox equivalent is that you meant to say
  ">From" with the ">", but the receiver turned it into just "From".

So I don't think it's a totally wrong direction to go. But like I said,
it doesn't seem to happen often enough in practice that anybody has been
motivated to add the feature.

-Peff




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux