Preserve Git config escape semantics · gitpython-developers/GitPython@ef3fb51 · GitHub
Skip to content

Commit ef3fb51

Browse files
codexByron
authored andcommitted
Preserve Git config escape semantics
Decode Git-supported quoted value escapes directly instead of routing UTF-8 text through Python unicode_escape. This preserves newlines, quotes, backslashes, and non-ASCII text when an unrelated config update rewrites existing values. Reject carriage returns and NULs at the shared writer sink so values parsed from existing files cannot place unsafe control characters into rewritten config files. Git itself does not accept \r as a config escape, so rejection is the compatible safe behavior. Regression coverage rewrites representative quoted values, compares GitPython and git-config results, and verifies CR/NUL rejection. Validated with the complete config test module, Ruff, and mypy. Behavior checked against Git cf5497b14c5a, particularly config.c parse_value(), which supports \n, \t, \b, \\, and \" and rejects unknown escapes.
1 parent 52a6cba commit ef3fb51

2 files changed

Lines changed: 76 additions & 12 deletions

File tree

git/config.py

Lines changed: 22 additions & 5 deletions

test/test_config.py

Lines changed: 54 additions & 7 deletions

0 commit comments

Comments
 (0)