Title: Don't remove quotes if `\` or `"` are present inside by EliahKagan · Pull Request #2048 · gitpython-developers/GitPython · GitHub
Open Graph Title: Don't remove quotes if `\` or `"` are present inside by EliahKagan · Pull Request #2048 · gitpython-developers/GitPython
X Title: Don't remove quotes if `\` or `"` are present inside by EliahKagan · Pull Request #2048 · gitpython-developers/GitPython
Description: Background #2035 fixed issue #1923, where the ConfigParser would not remove the quotes around single-line values. As discussed in comments there: That improved the common cases where quote removal is all that is needed, in particular where no escape sequences are present. When there are escape sequences within a single line quoted value, that was already not handled correctly--since no single-line quoted values (other than a quoted empty string) had been handled correctly before #2035, in that quote removal was never performed for them. Nonetheless, #2035 may have made the situation worse for some applications if they handled the quoted values themselves, or if the quoted values were more readily recognized to mean parsing had not succeeded. Let's take the best of both worlds (so far) This PR keeps the changes from #2035 in the case that they work because the text contained strictly between the beginning and ending " characters contains neither any \ nor any other ". This both: Preserves the benefit of #2035 for #1923. (The only exception is cases where a \ is meant to be preserved rather than treated as an escape character. This is presumably rare--if it ever happens--since that's not the syntax of double-quoted values in Git config files.) Keeps the old, potentially safer behavior of doing no transformations, not even quote removal, in cases where quote removal alone would clearly not produce the correct result. Changes c8e4aa0 refactors to prepare for the other changes. 7bcea08 adds a test for the behavior described above. f2b8041 makes those tests pass. But it can get better than this This is not intended as a long-term alternative to parsing escape sequences. The idea in #2035 (comment) of handling them is good, and this is not meant to discourage or interfere with that. The new test fixture and test can be modified accordingly. See the docstring and comments in test_config_with_quotes_containing_escapes. For review It seems to me that the idea here is sound, since it restores the main branch to a state where no changes are expected to produce problems for programs and libraries that use GitPython, if a patch release were to be made. But even if I am right to think that, there are a few reasons it may be useful to have a review here before merging: I'm less familiar with the config parser than most of the rest of the code of GitPython, so there could be design subtleties I am missing. There are multiple reasonable ways to make this change, and you may have input, stylistically or otherwise. It's easy to introduce bugs when making nontrivial (even if small) changes to parsing logic. (This follows #2046 and #2047, which followed #2035 and #2036.)
Open Graph Description: Background #2035 fixed issue #1923, where the ConfigParser would not remove the quotes around single-line values. As discussed in comments there: That improved the common cases where quote removal...
X Description: Background #2035 fixed issue #1923, where the ConfigParser would not remove the quotes around single-line values. As discussed in comments there: That improved the common cases where quote removal...
Opengraph URL: https://github.com/gitpython-developers/GitPython/pull/2048
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:6590bb23-ef4e-84de-fa49-c214ba60ed52 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E0FC:3B80:D292BF:11B9519:69687F64 |
| html-safe-nonce | 9dc713f4d43e836d238fec10de48ec63c9b993cb581b383cd44d9de585a1f1c2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMEZDOjNCODA6RDI5MkJGOjExQjk1MTk6Njk2ODdGNjQiLCJ2aXNpdG9yX2lkIjoiMzI5NjYxOTU0MDEzNTgzNzU0MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 21b1cbdd31e1dfe1ebc69a5219b28163329f477e76f3dc0de2c9755ee83d458e |
| hovercard-subject-tag | pull_request:2576321204 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/gitpython-developers/GitPython/pull/2048/files |
| twitter:image | https://avatars.githubusercontent.com/u/1771172?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1771172?s=400&v=4 |
| og:image:alt | Background #2035 fixed issue #1923, where the ConfigParser would not remove the quotes around single-line values. As discussed in comments there: That improved the common cases where quote removal... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 50f46dc2d6192249fd8ebf20e76c800f4f2596d4a5f3ab63dd63a754df154f54 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | fef287f17234b4529a4b112a3d47fe8551e32ddd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width