GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||
GeezerVison is showing github.com — Fix GitConfigParser not removing quotes from values by betaboon · Pull Request #2035 · gitpython-developers/GitPython Conversation
Contributor
closes #1923
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
betaboon
force-pushed
the
fix-configparser-quotes
branch
from
d233b4c to
67468a2
Compare
Byron
approved these changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's great, thank you!
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
EliahKagan
reviewed
|
|
@betaboon Maybe you could provide us with a follow-up PR that handles the escape sequences which may be present inside of quoted values, to more correctly capture this. After all, the GitPython Git configuration parser is just an adapted INI parser, and that is inherently unable to capture all the subtleties, but we can try harder where we can - this is clearly one such opportunity. For anything serious, it's better to use |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The ConfigParser has supported this for a long time, but it is now done redundantly since gitpython-developers#2035. This adds a test for it, both to make clearer that it is intended to work and to allow verifying that it continues to hold once the legacy special-casing for it is removed.
The ConfigParser has supported this for a long time, but it is now done redundantly since gitpython-developers#2035. This adds a test for it, both to make clearer that it is intended to work and to allow verifying that it continues to hold once the legacy special-casing for it is removed.
Because `""` is a special case of `"..."` as parsed since gitpython-developers#2035.
This is for single line quoting in the ConfigParser. This leaves the changes in gitpython-developers#2035 (as adjusted in gitpython-developers#2036) intact for the cases where it addressed gitpython-developers#1923: when the `...` in `"..."` (appearing in the value position on a single `{name} = {value}"` line) has no occurrences of `\` or `"`, quote removal is enough. But when `\` or `"` does appear, this suppresses quote removal. This is with the idea that, while it would be better to interpret such lines as Git does, we do not yet do that, so it is preferable to return the same results we have in the past (which some programs may already be handling themselves). This should make the test introduced in the preceding commit pass. But it will be even better to support more syntax, at least well-formed escapes. As noted in the test, both the test and the code under test can be adjusted for that. (See comments in gitpython-developers#2035 for context.)
Because literal `""` is a special case of `"..."` as parsed since gitpython-developers#2035.
This is for single line quoting in the ConfigParser. This leaves the changes in gitpython-developers#2035 (as adjusted in gitpython-developers#2036) intact for the cases where it addressed gitpython-developers#1923: when the `...` in `"..."` (appearing in the value position on a single `{name} = {value}"` line) has no occurrences of `\` or `"`, quote removal is enough. But when `\` or `"` does appear, this suppresses quote removal. This is with the idea that, while it would be better to interpret such lines as Git does, we do not yet do that, so it is preferable to return the same results we have in the past (which some programs may already be handling themselves). This should make the test introduced in the preceding commit pass. But it will be even better to support more syntax, at least well-formed escapes. As noted in the test, both the test and the code under test can be adjusted for that. (See comments in gitpython-developers#2035 for context.)
This is for single line quoting in the ConfigParser. This leaves the changes in gitpython-developers#2035 (as adjusted in gitpython-developers#2036) intact for the cases where it addressed gitpython-developers#1923: when the `...` in `"..."` (appearing in the value position on a single `{name} = {value}"` line) has no occurrences of `\` or `"`, quote removal is enough. But when `\` or `"` does appear, this suppresses quote removal. This is with the idea that, while it would be better to interpret such lines as Git does, we do not yet do that, so it is preferable to return the same results we have in the past (which some programs may already be handling themselves). This should make the test introduced in the preceding commit pass. But it will be even better to support more syntax, at least well-formed escapes. As noted in the test, both the test and the code under test can be adjusted for that. (See comments in gitpython-developers#2035 for context.)
|
@EliahKagan beat me to it. thanks a bunch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I actually have not implemented handling of escape sequences. If you mean #2048, that detects if the string may contain escape sequences (or if it may have a closing quotation mark before the one at the end of the line). If so, avoids removing the outer quotes at all. Otherwise, it allows them to be removed. For example, if we merge #2048, then:
While that should be enough to avoid breaking existing code as described in #2035 (review), it is not as good as actually translating the escape sequences as suggested in #2035 (comment). The five recognized escape sequences for double-quoted values in Git configuration files are described in the last paragraph of the "Syntax" section of git-config(1):
You are certainly under no obligation! However, if you are interested in adding handling for escape sequences, then I think you could still do so--either after, or instead of, #2048--and hopefully nothing I have done would get in the way. (Actually, I think #2048 might make it easier to proceed with adding translation of escape sequences, or other changes.) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
i took a look at #2048. that seems like a good way forward. tbh: i never anticipated my (seemingly trivial) change from #2035 to start this rabbit hole. I'm glad you caught this. just for clarity: if after #2048 you feel like going ahead for the escape sequences, go ahead. i really can't promise i find the time to do so any time soon. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This is for single line quoting in the ConfigParser. This leaves the changes in gitpython-developers#2035 (as adjusted in gitpython-developers#2036) intact for the cases where it addressed gitpython-developers#1923: when the `...` in `"..."` (appearing in the value position on a single `{name} = {value}"` line) has no occurrences of `\` or `"`, quote removal is enough. But when `\` or `"` does appear, this suppresses quote removal. This is with the idea that, while it would be better to interpret such lines as Git does, we do not yet do that, so it is preferable to return the same results we have in the past (which some programs may already be handling themselves). This should make the test introduced in the preceding commit pass. But it will be even better to support more syntax, at least well-formed escapes. As noted in the test, both the test and the code under test can be adjusted for that. (See comments in gitpython-developers#2035 for context.)
This is for single line quoting in the ConfigParser. This leaves the changes in gitpython-developers#2035 (as adjusted in gitpython-developers#2036) intact for the cases where it addressed gitpython-developers#1923: when the `...` in `"..."` (appearing in the value position on a single `{name} = {value}"` line) has no occurrences of `\` or `"`, quote removal is enough. But when `\` or `"` does appear, this suppresses quote removal. This is with the idea that, while it would be better to interpret such lines as Git does, we do not yet do that, so it is preferable to return the same results we have in the past (which some programs may already be handling themselves). This should make the test introduced in the preceding commit pass. But it will be even better to support more syntax, at least well-formed escapes. As noted in the test, both the test and the code under test can be adjusted for that. (See comments in gitpython-developers#2035 for context.)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
GitConfigParser misparses quotes in options
There was an error while loading. Please reload this page.