60 lines
2.3 KiB
Diff
60 lines
2.3 KiB
Diff
From 356c473295097f4aeaacc1a2dcd70271b7080788 Mon Sep 17 00:00:00 2001
|
|
From: Nikita Leonov <nykyta.leonov@gmail.com>
|
|
Date: Sat, 3 Oct 2020 13:29:12 +0000
|
|
Subject: [PATCH] credential: treat CR/LF as line endings in the credential
|
|
protocol
|
|
|
|
This fix makes using Git credentials more friendly to Windows users: it
|
|
allows a credential helper to communicate using CR/LF line endings ("DOS
|
|
line endings" commonly found on Windows) instead of LF-only line endings
|
|
("Unix line endings").
|
|
|
|
Note that this changes the behavior a bit: if a credential helper
|
|
produces, say, a password with a trailing Carriage Return character,
|
|
that will now be culled even when the rest of the lines end only in Line
|
|
Feed characters, indicating that the Carriage Return was not meant to be
|
|
part of the line ending.
|
|
|
|
In practice, it seems _very_ unlikely that something like this happens.
|
|
Passwords usually need to consist of non-control characters, URLs need
|
|
to have special characters URL-encoded, and user names, well, are names.
|
|
|
|
However, it _does_ help on Windows, where CR/LF line endings are common:
|
|
as unrecognized commands are simply ignored by the credential machinery,
|
|
even a command like `quit\r` (which is clearly intended to abort) would
|
|
simply be ignored (silently) by Git.
|
|
|
|
So let's change the credential machinery to accept both CR/LF and LF
|
|
line endings.
|
|
|
|
While we do this for the credential helper protocol, we do _not_ adjust
|
|
`git credential-cache--daemon` (which won't work on Windows, anyway,
|
|
because it requires Unix sockets) nor `git credential-store` (which
|
|
writes the file `~/.git-credentials` which we consider an implementation
|
|
detail that should be opaque to the user, read: we do expect users _not_
|
|
to edit this file manually).
|
|
|
|
Signed-off-by: Nikita Leonov <nykyta.leonov@gmail.com>
|
|
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
|
---
|
|
credential.c | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/credential.c b/credential.c
|
|
index efc29dc5e1..e5202fbef2 100644
|
|
--- a/credential.c
|
|
+++ b/credential.c
|
|
@@ -202,7 +202,7 @@ int credential_read(struct credential *c, FILE *fp)
|
|
{
|
|
struct strbuf line = STRBUF_INIT;
|
|
|
|
- while (strbuf_getline_lf(&line, fp) != EOF) {
|
|
+ while (strbuf_getline(&line, fp) != EOF) {
|
|
char *key = line.buf;
|
|
char *value = strchr(key, '=');
|
|
|
|
--
|
|
2.33.0
|
|
|