From: Junio C Hamano <gitster@pobox.com>
To: Antonio De Stefani <antonio.destefani08@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] gpg-interface: fix strip_cr_before_lf to only remove CR before LF
Date: Wed, 24 Jun 2026 09:58:25 -0700 [thread overview]
Message-ID: <xmqqfr2bkh8u.fsf@gitster.g> (raw)
In-Reply-To: <20260624093618.17456-1-antonio.destefani08@gmail.com> (Antonio De Stefani's message of "Wed, 24 Jun 2026 11:36:18 +0200")
Antonio De Stefani <antonio.destefani08@gmail.com> writes:
> c4adea82 (Convert CR/LF to LF in tag signatures, 2008-07-11)
> introduced CR stripping for GPG output on Windows, but intentionally
> stripped all CR characters unconditionally to "keep the code simpler",
> even though only \r\n sequences (Windows line endings) needed to be
> normalized. 2f47eae2 (Split GPG interface into its own helper library,
> 2011-09-07) moved the code into gpg-interface.c, and 29b31577 (ssh
> signing: add ssh key format and signing code, 2021-09-10) extracted
> it into the remove_cr_after() helper when adding SSH signing support.
>
> The original laziness was safe at the time because lone CR characters
> are not expected in GPG signature output. However, the NEEDSWORK
> comment left by a previous reader correctly identified that only
> \r\n pairs should be stripped, not lone \r characters.
>
> Fix the loop to skip \r only when immediately followed by \n, keeping
> lone trailing CR characters intact. Rename the function to
> strip_cr_before_lf to reflect its corrected behavior, and update
> both call sites and their comments accordingly.
>
> Signed-off-by: Antonio De Stefani <antonio.destefani08@gmail.com>
> ---
> gpg-interface.c | 25 +++++++++++--------------
> 1 file changed, 11 insertions(+), 14 deletions(-)
Looking good. Will queue. Thanks.
next prev parent reply other threads:[~2026-06-24 16:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-24 9:36 [PATCH] gpg-interface: fix strip_cr_before_lf to only remove CR before LF Antonio De Stefani
2026-06-24 16:58 ` Junio C Hamano [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-06-23 8:45 DSAntonio08
2026-06-23 15:09 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqfr2bkh8u.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=antonio.destefani08@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox