Skip to content

Incorrect handling of backslashes in Git configuration #44

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

Closed
ereOn opened this issue Feb 7, 2012 · 1 comment
Closed

Incorrect handling of backslashes in Git configuration #44

ereOn opened this issue Feb 7, 2012 · 1 comment

Comments

@ereOn
Copy link

ereOn commented Feb 7, 2012

Steps to reproduce the issue:

import git
config = git.Repo().config_writer()
config.add_section('test')
config.set_value('test', 'test', r'some\data')

Now if you try to read this value using a regular (non Python) git config, Git complains that the configuration file is invalid:

fatal: bad config file line 11 in .git/config

Indeed, if you open .git/config you can see that the value is written as:

[test]
  test = some\data

While the git-config configuration states that:

String values may be entirely or partially enclosed in double quotes. You need to enclose variable values in double quotes if you want to preserve leading or trailing whitespace, or if the variable value contains comment characters (i.e. it contains # or ;). Double quote " and backslash \ characters in variable values must be escaped: use " for " and \ for .

That is, the backslashes are not escaped in the configuration file.

This also cause issues in while reading, because values are not un-escaped.

@ereOn
Copy link
Author

ereOn commented Feb 7, 2012

I made a pull-request instead.

@ereOn ereOn closed this as completed Feb 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant