Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitConfigParser misparses quotes in options #1923

Open
cjwatson opened this issue May 31, 2024 · 2 comments
Open

GitConfigParser misparses quotes in options #1923

cjwatson opened this issue May 31, 2024 · 2 comments

Comments

@cjwatson
Copy link

My ~/.gitconfig starts like this:

[user]
        name = "Colin Watson"
        email = "[email protected]"

It's been like that for a long time, so I don't remember whether an old version of git config wrote it like that, or whether I put it there by hand. Anyway, git itself has always been fine with this. The relevant part of git-config(1) says:

A line that defines a value can be continued to the next line by ending it with a ; the backslash and the end-of-line are stripped. Leading whitespaces after name =, the remainder of the line after the first comment character # or ;, and trailing whitespaces of the line are discarded unless they are enclosed in double quotes. Internal whitespaces within the value are retained verbatim.

Inside double quotes, double quote " and backslash \ characters must be escaped: use " for " and \ for .

The following escape sequences (beside " and \) are recognized: \n for newline character (NL), \t for horizontal tabulation (HT, TAB) and \b for backspace (BS). Other char escape sequences (including octal escape sequences) are invalid.

But when I create a commit using IndexFile.commit(), I get this in the commit metadata, which I'm pretty sure is malformed:

Author: "Colin Watson" <"[email protected]">

I think GitConfigParser should match the parsing rules that git config follows.

@Byron
Copy link
Member

Byron commented Jun 1, 2024

Thanks a lot for reporting!

The config parser here is based on the INI config parser, which makes it very much non-conforming to the Git specification.
Fixes on top of that can certainly be done though, hoping they won't introduce more problems than they solve.

@katexochen
Copy link

This is a problem as GitHub won't recognize the quoted version, so commits aren't liked to the authors profile.

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

No branches or pull requests

3 participants