René's URL Explorer Experiment


Title: GitConfigParser does not decode backslash escapes in unquoted config values · Issue #2296 · gitpython-developers/GitPython · GitHub

Open Graph Title: GitConfigParser does not decode backslash escapes in unquoted config values · Issue #2296 · gitpython-developers/GitPython

X Title: GitConfigParser does not decode backslash escapes in unquoted config values · Issue #2296 · gitpython-developers/GitPython

Description: This was found and prepared with AI assistance (drafted by Codex, posted through the account owner's account); the reproduction and analysis below are agent-authored. Description GitConfigParser leaves backslash escapes literal in unquot...

Open Graph Description: This was found and prepared with AI assistance (drafted by Codex, posted through the account owner's account); the reproduction and analysis below are agent-authored. Description GitConfigParser le...

X Description: This was found and prepared with AI assistance (drafted by Codex, posted through the account owner's account); the reproduction and analysis below are agent-authored. Description GitConfigParse...

Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/2296

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"GitConfigParser does not decode backslash escapes in unquoted config values","articleBody":"This was found and prepared with AI assistance (drafted by Codex, posted through the account owner's account); the reproduction and analysis below are agent-authored.\n\n## Description\n\n`GitConfigParser` leaves backslash escapes literal in **unquoted** config values, so it disagrees with Git on the same file. Quoted values are handled correctly today; the unquoted path only decoded escapes when the value continued onto the next line, so a single-line unquoted value kept its escapes verbatim.\n\n| config | Git | GitPython (before) |\n| --- | --- | --- |\n| `b = first\\nsecond` | `first\u003cLF>second` | `first\\nsecond` |\n| `b = first\\tsecond` | `first\u003cTAB>second` | `first\\tsecond` |\n| `b = foo\\\\bar` | `foo\\bar` | `foo\\\\bar` |\n| `b = ab\\\"cd` | `ab\"cd` | `ab\\\"cd` |\n\nThe same value also decoded differently depending only on whether it was wrapped, which is the inconsistency that points at the cause:\n\n| config | Git | GitPython (before) |\n| --- | --- | --- |\n| `b = first\\nsecond` | `first\u003cLF>second` | `first\\nsecond` |\n| `b = first\\nsecond \\`\u003cbr>`    z` | `first\u003cLF>second z` | `first\u003cLF>second z` |\n\nBeyond reading the wrong value, this makes rewriting unsafe. Because the parsed value contained no control character, the writer's CR/LF/NUL guard did not trigger, so saving an unrelated key emitted a value Git then read differently than before:\n\n```\noriginal:    [a]\\n\\tb = x\\\\ny\\n\ngit reads:   x\u003cLF>y\nGitPython:   x\\ny            # literal backslash, no control char\nrewritten:   [a]\\n\\tb = \"x\\\\\\\\ny\\\\\\n\"\\n\ngit reads:   x\\\\ny           # changed meaning, file was corrupted by a read-modify-write\n```\n\n## Reproduction\n\n```python\nfrom git import GitConfigParser\n\nwith open(\"/tmp/config\", \"w\") as f:\n    f.write(\"[a]\\n\\tb = first\\\\nsecond\\n\")\n\nprint(repr(GitConfigParser(\"/tmp/config\", read_only=True).get_value(\"a\", \"b\")))\n```\n\nBefore: `'first\\\\nsecond'`. Expected, and what git prints: `'first\\nsecond'`.\n\nCompare against real git:\n\n```console\n$ GIT_CONFIG_GLOBAL=/tmp/config GIT_CONFIG_SYSTEM=/dev/null git config --get a.b | od -c\n0000000    f   i   r   s   t  \\n   s   e   c   o   n   d  \\n\n```\n\n## Root cause\n\n`git/config.py:624` in `GitConfigParser._read` — `parse_value()` was invoked only when `continued` was set:\n\n```python\n        continued = False\n        while True:\n            if not is_line_continuation(optval):\n                break\n            ...\n            continued = True\n        if continued:\n            optval = parse_value(optval)\n```\n\n`parse_value()` is the routine that decodes escapes, strips unquoted comments and trims whitespace. Guarding it on `continued` meant a single-line unquoted value skipped it entirely, while a value that happened to continue got the full decode. The quoted branches a few lines below already decoded unconditionally.\n\n## A caveat that shapes the fix\n\nGit decodes the standard escape sequences (`\\n`, `\\t`, `\\b`, `\\\\`, `\\\"`) 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.\n\n```\n$ printf '[a]\\n\\tb = C:\\\\Users\\n' > c\n$ GIT_CONFIG_GLOBAL=c GIT_CONFIG_SYSTEM=/dev/null git config --get a.b\nfatal: bad config line 2 in file c\n```\n\nSo `path = C:\\Users\\me` is not something git can read at all. GitPython is deliberately more tolerant here — it keeps such backslashes literal, which is what lets a Windows path survive a round-trip — and several existing tests depend on that tolerance.\n\nDecoding unconditionally would therefore regress it: in `C:\\Users\\...\\Temp\\test_foo`, the `\\t` of `\\Temp` and `\\test` would become tabs while the `\\U` of `\\Users` stayed literal, corrupting the path. That broke four `test_conditional_includes_*` / `test_multiple_include_paths_with_same_key` tests on Windows in a first attempt.\n\n## Suggested fix\n\nCall `parse_value()` when every backslash in the value introduces a known escape, and leave the value untouched otherwise. This keeps the tolerance for unknown escapes intact while fixing the decode:\n\n- `first\\nsecond`, `a\\tb`, `foo\\\\bar` — all backslashes are known escapes, so they are decoded as git does.\n- `C:\\Users\\...\\Temp\\test_foo` — contains the unknown `\\U`, so the whole value stays literal and the path is preserved.\n\nThe escape table moves to a module-level `UNQUOTED_ESCAPES` so the decoder and this guard cannot drift apart.\n\nOne existing expectation encodes the current behaviour and would need to move with it: `test_backslash_line_continuation` asserts `k = val\\\\` followed by a newline reads as `val\\\\`, while git yields `val\\` (the second backslash escapes the first, so there is no continuation).\n\nI can put up the PR with the fix and regression tests.\n","author":{"url":"https://github.com/JingHao-Leon","@type":"Person","name":"JingHao-Leon"},"datePublished":"2026-10-19T10:44:05Z","url":"https://github.com/gitpython-developers/GitPython/issues/2296"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:73f217b2-6f94-c2cb-d027-c8d5eb9d208e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBF60:154D88:313AC9:3E6A5D:6B0103D3
html-safe-nonce8c842283f506045e46f30539a78a0da3ece351722d22e70a487eef3fc5facacc
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjYwOjE1NEQ4ODozMTNBQzk6M0U2QTVEOjZCMDEwM0QzIiwidmlzaXRvcl9pZCI6Ijg5NzE1ODI5Njk2NTEyMDA5NzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac66067a97d395bb71cea993653c0ed013a40ea92b6dd2992f7ea2da3bb3ed30b5
hovercard-subject-tagissue:5922399001
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/2296/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c966a40decd56763ff6086ebb81a6a36112cb877d9472965c057d98b6cf5b722/gitpython-developers/GitPython/issues/2296
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c966a40decd56763ff6086ebb81a6a36112cb877d9472965c057d98b6cf5b722/gitpython-developers/GitPython/issues/2296
og:image:altThis was found and prepared with AI assistance (drafted by Codex, posted through the account owner's account); the reproduction and analysis below are agent-authored. Description GitConfigParser le...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameJingHao-Leon
hostnamegithub.com
expected-hostnamegithub.com
Nonecb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124
turbo-cache-controlno-preview
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
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/gitpython-developers/GitPython/issues/2296#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fissues%2F2296
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%2Fissues%2F2296
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=gitpython-developers%2FGitPython
Reloadhttps://github.com/gitpython-developers/GitPython/issues/2296
Reloadhttps://github.com/gitpython-developers/GitPython/issues/2296
Reloadhttps://github.com/gitpython-developers/GitPython/issues/2296
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
https://github.com/gitpython-developers/GitPython
New issuehttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/2296
New issuehttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/2296
#2297https://github.com/gitpython-developers/GitPython/pull/2297
GitConfigParser does not decode backslash escapes in unquoted config valueshttps://github.com/gitpython-developers/GitPython/issues/2296#top
#2297https://github.com/gitpython-developers/GitPython/pull/2297
https://github.com/JingHao-Leon
JingHao-Leonhttps://github.com/JingHao-Leon
on Oct 19, 2026https://github.com/gitpython-developers/GitPython/issues/2296#issue-5922399001
Byronhttps://github.com/Byron
completedhttps://github.com/gitpython-developers/GitPython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#2297https://github.com/gitpython-developers/GitPython/pull/2297
on Oct 21, 2026https://github.com/gitpython-developers/GitPython/issues/2296#event-33848786593
Sign up for freehttps://github.com/signup?return_to=https://github.com/gitpython-developers/GitPython/issues/2296
Sign in to commenthttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/2296
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.