Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Incorrect handling of backslashes and quotes in GitConfigParser#46

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 3 commits intogitpython-developers:masterfromereOn:master
May 30, 2012

Conversation

ereOn
Copy link

Steps to reproduce the issue:

import gitconfig = 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 thegit-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 causes issues while reading, because values are not un-escaped.

This pull request fixes both those issues and also fixes unescaped quotes pairs.

A test-case has been provided along with the fixes.

@Byron
Copy link
Member

Thanks for your effort !

As I want to give the merge more attention, I hope you are okay with me not merging it right away.
However, if you are held off by the delay, please let me know.

@ereOn
Copy link
Author

No problem.

I will leave the clone in my own Github account until you merge it.

I'm not in a hurry for this fix (I applied the same fix in my code using GitPython, so things work for me now) but I guess other people are likely to face the same problem as it is easily reproducible.

@ereOn
Copy link
Author

@Byron: Have you planned to merge this soon ? I intended to do some cleanup of my github account and I'm only keeping my clone of GitPython because of this pending pull-request.

Byron added a commit that referenced this pull requestMay 30, 2012
Incorrect handling of backslashes and quotes in GitConfigParserSteps to reproduce the issue:import gitconfig = 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/configIndeed, if you open .git/config you can see that the value is written as:[test]  test = some\dataWhile 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 causes issues while reading, because values are not un-escaped.This pull request fixes both those issues and also fixes unescaped quotes pairs.A test-case has been provided along with the fixes.
@ByronByron merged commitcd72d78 intogitpython-developers:masterMay 30, 2012
@Byron
Copy link
Member

Thanks for bringing this up.
Had no time to test and/or verify it myself yet, but I will do this once I am back on the project.

Feel free to delete your clone, and
thanks for you work !

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@ereOn@Byron

[8]ページ先頭

©2009-2025 Movatter.jp