Skip to content

credential-store: accept CRLF as EOL - #6425

Draft
rimrul wants to merge 1 commit into
git-for-windows:mainfrom
rimrul:credentioal-store-crlf
Draft

rimrul wants to merge 1 commit into
git-for-windows:mainfrom
rimrul:credentioal-store-crlf

Conversation

@rimrul

@rimrul rimrul commented Sep 18, 2026

Copy link
Copy Markdown
Member

git-credential store treats only LF as an EOL character, but reads the CR in a CR terminated line as part of the entry. Since the entries are URLs, CR can never be a valid character in an entry.

While we don't encourage users to manually edit the credential file, the format is simple enough and documented well enough that users do sometimes do that. Most editors on Windows produce CRLF as EOL characters. Users currently need to be careful when manually editing the credential file on Windows to not add stray CR characters into the file.

We have tests around when we consider entries with CRLF valid and not valid, but they only seem to test the known quirks of the existing implementation, not some expectations founded in some systemic design decisions.

Since the entries can never validly contain a CR character we should just treat CRLF as an EOL character. Start treating it that way and adjust the old tests.

git-credential store treats only LF as an EOL character, but reads the
CR in a CR terminated line as part of the entry. Since the entries are
URLs, CR can never be a valid character in an entry. [1]

While we don't encourage users to manually edit the credential file, the
format is simple enough and documented well enough that users do
sometimes do that. Most editors on Windows produce CRLF as EOL
characters. Users currently need to be careful when manually editing
the credential file on Windows to not add stray CR characters into the
file.

We have tests around when we consider entries with CRLF valid and not
valid, but they only seem to test the known quirks of the existing
implementation, not some expectations founded in some systemic design
decisions.

Since the entries can never validly contain a CR character we should
just treat CRLF as an EOL character. Start treating it that way and
adjust the old tests.

[1] https://www.rfc-editor.org/info/rfc1738/#section-2.2

Signed-off-by: Matthias Aßhauer <mha1993@live.de>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git fails to detect valid credentials when they are stored in a local file with Windows (CRLF) line endings

1 participant