René's URL Explorer Experiment


Title: fix(config): decode escapes in unquoted config values by JingHao-Leon · Pull Request #2297 · gitpython-developers/GitPython · GitHub

Open Graph Title: fix(config): decode escapes in unquoted config values by JingHao-Leon · Pull Request #2297 · gitpython-developers/GitPython

X Title: fix(config): decode escapes in unquoted config values by JingHao-Leon · Pull Request #2297 · gitpython-developers/GitPython

Description: Description GitConfigParser leaves backslash escapes literal in unquoted config values, so it disagrees with Git on the same file. Quoted values are decoded correctly; unquoted ones are not. config git config --get a.b GitPython before b = first\nsecond firstsecond first\nsecond b = first\tsecond firstsecond first\tsecond b = foo\\bar foo\bar foo\\bar b = ab\"cd ab"cd ab\"cd The value also decoded differently depending only on whether it was wrapped, which is the inconsistency that identifies the cause: b = first\nsecond stayed literal, while b = first\nsecond \ continued onto a second line was decoded. This also made read-modify-write corrupt config files. The parsed value held no control character, so the writer's CR/LF/NUL guard never triggered, and saving an unrelated key changed what Git read: original: [a]\n\tb = x\\ny\n git reads: xy GitPython: x\ny (literal backslash, no control char) rewritten: [a]\n\tb = "x\\\\ny\\\n"\n git reads: x\\ny (value changed meaning) After the fix GitPython reads xy like Git does, and the existing writer guard rejects the control character instead of corrupting the file. Root cause git/config.py:624 — parse_value() was called only when continued was set: continued = False while True: if not is_line_continuation(optval): break ... continued = True if continued: optval = parse_value(optval) parse_value() is what decodes escapes, strips unquoted comments and trims whitespace. Gating it on continued made the decode depend on line wrapping, so a single-line unquoted value skipped it while a continued one got it. Why the decode is conditional on the escapes being known Git decodes the standard escape sequences in unquoted values as well, but it is not accurate to say it treats unquoted values exactly as it treats quoted ones: for an escape it does not recognise, git rejects the line outright. $ printf '[a]\n\tb = C:\\Users\n' > c $ GIT_CONFIG_GLOBAL=c GIT_CONFIG_SYSTEM=/dev/null git config --get a.b fatal: bad config line 2 in file c So path = C:\Users\me is not a line git can read at all. GitPython is deliberately more tolerant and keeps such backslashes literal, which is what lets a Windows path survive a round-trip, and existing tests depend on it. Decoding unconditionally regresses that tolerance. In C:\Users\RUNNER~1\AppData\Local\Temp\test_foo, the \t of \Temp and \test became tabs while the \U of \Users stayed literal, so the path no longer matched. That is not hypothetical: it turned four Windows jobs red on the first push of this branch — test_config.py::TestBase::test_conditional_includes_from_git_dir test_config.py::TestBase::test_conditional_includes_from_branch_name test_config.py::TestBase::test_conditional_includes_remote_url test_config.py::TestBase::test_multiple_include_paths_with_same_key I did not touch those tests to match the new behaviour, since that would only hide the regression. Instead parse_value() now runs only when every backslash in the value introduces a known escape: first\nsecond, a\tb, foo\\bar — all backslashes known, so decoded as git does. C:\Users\...\Temp\test_foo — contains the unknown \U, so the whole value stays literal and the path is preserved. The escape table moved to a module-level UNQUOTED_ESCAPES so the decoder and the new escapes_are_known() guard cannot drift apart. A trailing backslash is treated as known, since git drops it rather than treating it as an unknown escape; without that, a value ending in \ after a continuation would stop being comment-stripped. One existing expectation moves with this: test_backslash_line_continuation asserted k = val\\ followed by a newline reads as val\\. Git yields val\, since the second backslash escapes the first and there is no continuation, so that case now asserts the value Git actually produces. Validation All figures are from this branch against git 2.50.1 (Apple Git-155). Every expected value in the new fixture was first read out of real git config --get rather than assumed. New regression test, red before the fix: $ PYTHONPATH="$PWD" python -m pytest test/test_config.py::TestBase::test_config_with_unquoted_escapes -q E AssertionError: 'first\\nsecond' != 'first\nsecond' 1 failed in 0.21s Config suite after the fix: $ PYTHONPATH="$PWD" python -m pytest test/test_config.py -q -p no:randomly --no-cov 54 passed, 2 skipped, 29 subtests passed in 1.64s (before the change: 53 passed, 2 skipped — the extra test is the new one.) Full suite, same tree, before and after: before: 870 passed, 76 skipped, 913 errors, 53 subtests passed (260.81s) after: 871 passed, 76 skipped, 913 errors, 53 subtests passed (253.28s) The +1 is the new test; skipped and error counts are identical. The 913 errors are environmental and not related to this change: the sandbox clone is blobless, so test/lib/helper.py::TestBase.setUpClass cannot materialise historical blobs for its two dependency fixtures and git gc aborts. Those same 913 errors are present on unmodified main, and the lazy-fetch path was disabled on both runs so neither hung. Lint, using the rule set from pyproject.toml (E, W, F, B, C4, TC004): $ python -m ruff check --config /tmp/ruff_real.toml git/config.py test/test_config.py All checks passed! $ python -m ruff format --check --config /tmp/ruff_real.toml git/config.py test/test_config.py 2 files already formatted What I could not verify locally I am on macOS, so the Windows path handling that drove the design above is not reproducible here — POSIX paths contain no backslashes. I checked the mechanism by feeding the exact Windows temp paths through GitConfigParser directly on this machine and confirming they now round-trip unchanged: C:\Users\RUNNER~1\AppData\Local\Temp\test_conditional_includes_from_git_dirjyqm_zla\config2 C:\Users\RUNNER~1\AppData\Local\Temp\test_multiple_include_paths_with_same_keyabc\config2 C:\Users\RUNNER~1\AppData\Local\Temp\test_conditional_includes_remote_urlxyz\config2 All three round-trip exactly. That exercises the same escapes_are_known() branch the four failing tests depend on, but it is not a substitute for running the Windows jobs, so the Windows CI result on this push is the real check. No changelog entry: CONTRIBUTING.md does not ask for one, doc/source/changes.rst has no unreleased section, and the comparable config fixes (#2213, #2245, #2227, #2211) did not touch it. Fixes #2296 This change was prepared with the assistance of an AI coding agent.

Open Graph Description: Description GitConfigParser leaves backslash escapes literal in unquoted config values, so it disagrees with Git on the same file. Quoted values are decoded correctly; unquoted ones are not. con...

X Description: Description GitConfigParser leaves backslash escapes literal in unquoted config values, so it disagrees with Git on the same file. Quoted values are decoded correctly; unquoted ones are not. con...

Opengraph URL: https://github.com/gitpython-developers/GitPython/pull/2297

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:7fdcbdcb-ae3e-98c5-0b32-d96c04d10521
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idAEE0:361639:D7C1CE:1209025:6B0103D6
html-safe-nonce67a786b995f168f49296f6f16d2c2fc71d632566e85cf38c0e8f692c172cd252
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRUUwOjM2MTYzOTpEN0MxQ0U6MTIwOTAyNTo2QjAxMDNENiIsInZpc2l0b3JfaWQiOiIxNTM4MzgwNDQxNjY3NTY4NTk4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac181566e9b3ff11fb5ecf2c0642ce7ded5b4586013bddbb89b1a3dcef91d17f9c
hovercard-subject-tagpull_request:4919708037
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/gitpython-developers/GitPython/pull/2297/files
twitter:imagehttps://avatars.githubusercontent.com/u/102573344?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/102573344?s=400&v=4
og:image:altDescription GitConfigParser leaves backslash escapes literal in unquoted config values, so it disagrees with Git on the same file. Quoted values are decoded correctly; unquoted ones are not. con...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git
octolytics-dimension-user_id503709
octolytics-dimension-user_logingitpython-developers
octolytics-dimension-repository_id1126087
octolytics-dimension-repository_nwogitpython-developers/GitPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1126087
octolytics-dimension-repository_network_root_nwogitpython-developers/GitPython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/gitpython-developers/GitPython/pull/2297/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fpull%2F2297%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fpull%2F2297%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=gitpython-developers%2FGitPython
Reloadhttps://github.com/gitpython-developers/GitPython/pull/2297/files
Reloadhttps://github.com/gitpython-developers/GitPython/pull/2297/files
Reloadhttps://github.com/gitpython-developers/GitPython/pull/2297/files
gitpython-developershttps://github.com/gitpython-developers
GitPythonhttps://github.com/gitpython-developers/GitPython
Codehttps://github.com/gitpython-developers/GitPython
Issues1 (1)https://github.com/gitpython-developers/GitPython/issues
Pull requestshttps://github.com/gitpython-developers/GitPython/pulls
Discussionshttps://github.com/gitpython-developers/GitPython/discussions
Actionshttps://github.com/gitpython-developers/GitPython/actions
Security and quality42 (42)https://github.com/gitpython-developers/GitPython/security
Insightshttps://github.com/gitpython-developers/GitPython/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fgitpython-developers%2FGitPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fgitpython-developers%2FGitPython%2Fissues%2Fnew%2Fchoose
Byronhttps://github.com/Byron
gitpython-developers:mainhttps://github.com/gitpython-developers/GitPython/tree/main
JingHao-Leon:fix/config-unquoted-escape-parsinghttps://github.com/JingHao-Leon/GitPython/tree/fix/config-unquoted-escape-parsing
Conversation 0 https://github.com/gitpython-developers/GitPython/pull/2297
Commits 3 https://github.com/gitpython-developers/GitPython/pull/2297/commits
Checks 47 https://github.com/gitpython-developers/GitPython/pull/2297/checks
Files changed 6 https://github.com/gitpython-developers/GitPython/pull/2297/files
fix(config): decode escapes in unquoted config values https://github.com/gitpython-developers/GitPython/pull/2297/files#top
Show all changes 3 commits https://github.com/gitpython-developers/GitPython/pull/2297/files
983e182 fix(config): decode escapes in unquoted config values JingHao-Leon Oct 19, 2026 https://github.com/gitpython-developers/GitPython/pull/2297/commits/983e182dadcc45146a3024eae4f6dc1079089d0c
22f137d review Byron Oct 21, 2026 https://github.com/gitpython-developers/GitPython/pull/2297/commits/22f137d9aa9099f16de600be536e7a0cd203bb58
6d81c05 Steer agents aware from the issue + PR combo Byron Oct 21, 2026 https://github.com/gitpython-developers/GitPython/pull/2297/commits/6d81c055e2a19a79932dd7d04f97ceade4f3565c
Clear filters https://github.com/gitpython-developers/GitPython/pull/2297/files
Please reload this pagehttps://github.com/gitpython-developers/GitPython/pull/2297/files
Please reload this pagehttps://github.com/gitpython-developers/GitPython/pull/2297/files
AGENTS.md https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-a54ff182c7e8acf56acfd6e4b9c3ff41e2c41a31c9b211b2deb9df75d9a478f9
CONTRIBUTING.md https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055
README.md https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
config.py https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-dd51b67c435dfba6f72cc0d08f99456393556623a0f098ac2808d1a7cb78d53a
git_config_unquoted_escapes https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-72a1bc0220d1d544c5d0eb0573be22b582f3b76de092121b4338949d498535e2
test_config.py https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-45fa5f8530eb815c0cf606032e587adedb04dc70e59b203535d51c44654cfc4d
AGENTS.mdhttps://github.com/gitpython-developers/GitPython/pull/2297/files#diff-a54ff182c7e8acf56acfd6e4b9c3ff41e2c41a31c9b211b2deb9df75d9a478f9
View file https://github.com/JingHao-Leon/GitPython/blob/6d81c055e2a19a79932dd7d04f97ceade4f3565c/AGENTS.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/gitpython-developers/GitPython/pull/2297/{{ revealButtonHref }}
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-a54ff182c7e8acf56acfd6e4b9c3ff41e2c41a31c9b211b2deb9df75d9a478f9
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-a54ff182c7e8acf56acfd6e4b9c3ff41e2c41a31c9b211b2deb9df75d9a478f9
CONTRIBUTING.mdhttps://github.com/gitpython-developers/GitPython/pull/2297/files#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055
View file https://github.com/JingHao-Leon/GitPython/blob/6d81c055e2a19a79932dd7d04f97ceade4f3565c/CONTRIBUTING.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/gitpython-developers/GitPython/pull/2297/{{ revealButtonHref }}
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055
README.mdhttps://github.com/gitpython-developers/GitPython/pull/2297/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
View file https://github.com/JingHao-Leon/GitPython/blob/6d81c055e2a19a79932dd7d04f97ceade4f3565c/README.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/gitpython-developers/GitPython/pull/2297/{{ revealButtonHref }}
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
git/config.pyhttps://github.com/gitpython-developers/GitPython/pull/2297/files#diff-dd51b67c435dfba6f72cc0d08f99456393556623a0f098ac2808d1a7cb78d53a
View file https://github.com/JingHao-Leon/GitPython/blob/6d81c055e2a19a79932dd7d04f97ceade4f3565c/git/config.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/gitpython-developers/GitPython/pull/2297/{{ revealButtonHref }}
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-dd51b67c435dfba6f72cc0d08f99456393556623a0f098ac2808d1a7cb78d53a
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-dd51b67c435dfba6f72cc0d08f99456393556623a0f098ac2808d1a7cb78d53a
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-dd51b67c435dfba6f72cc0d08f99456393556623a0f098ac2808d1a7cb78d53a
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-dd51b67c435dfba6f72cc0d08f99456393556623a0f098ac2808d1a7cb78d53a
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-dd51b67c435dfba6f72cc0d08f99456393556623a0f098ac2808d1a7cb78d53a
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-dd51b67c435dfba6f72cc0d08f99456393556623a0f098ac2808d1a7cb78d53a
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-dd51b67c435dfba6f72cc0d08f99456393556623a0f098ac2808d1a7cb78d53a
test/fixtures/git_config_unquoted_escapeshttps://github.com/gitpython-developers/GitPython/pull/2297/files#diff-72a1bc0220d1d544c5d0eb0573be22b582f3b76de092121b4338949d498535e2
View file https://github.com/JingHao-Leon/GitPython/blob/6d81c055e2a19a79932dd7d04f97ceade4f3565c/test/fixtures/git_config_unquoted_escapes
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/gitpython-developers/GitPython/pull/2297/{{ revealButtonHref }}
test/test_config.pyhttps://github.com/gitpython-developers/GitPython/pull/2297/files#diff-45fa5f8530eb815c0cf606032e587adedb04dc70e59b203535d51c44654cfc4d
View file https://github.com/JingHao-Leon/GitPython/blob/6d81c055e2a19a79932dd7d04f97ceade4f3565c/test/test_config.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/gitpython-developers/GitPython/pull/2297/{{ revealButtonHref }}
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-45fa5f8530eb815c0cf606032e587adedb04dc70e59b203535d51c44654cfc4d
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-45fa5f8530eb815c0cf606032e587adedb04dc70e59b203535d51c44654cfc4d
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-45fa5f8530eb815c0cf606032e587adedb04dc70e59b203535d51c44654cfc4d
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-45fa5f8530eb815c0cf606032e587adedb04dc70e59b203535d51c44654cfc4d
https://github.com/gitpython-developers/GitPython/pull/2297/files#diff-45fa5f8530eb815c0cf606032e587adedb04dc70e59b203535d51c44654cfc4d
Please reload this pagehttps://github.com/gitpython-developers/GitPython/pull/2297/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.