Fix IndexError in GitConfigParser When a Quoted Config Value Contains a Trailing New Line#1908
Conversation
Improve the guarding `if` check in `GitConfigParser`'s `string_decode` function to safely handle empty strings and prevent `IndexError`s when accessing string elements. This resolves an IndexError in the `GitConfigParser`'s `.read()` method when the config file contains a quoted value containing a trailing new line. Fixes: gitpython-developers#1887
Byron
left a comment
There was a problem hiding this comment.
Thanks a lot for this improvement!
I will merge right after CI is green after applying my tiny patch.
Sorry, something went wrong.
EliahKagan
left a comment
There was a problem hiding this comment.
I've suggested a small change that I think improves clarity.
Separately from the changes here but relevant to the logic they are a part of, I'm a bit worried about the case where there are two (or more) trailing backslashes, so that removing one of them still leaves a trailing backslash. However, that was present before, and this PR definitely need not be expanded to address it! I'm also not certain I'm right to be worried about that; maybe it is less important to cover, or a part of a separate class of malformed configuration file inputs that are intended to trigger decoding errors.
Sorry, something went wrong.
Thanks for taking another look - admittedly I forgot to merge this PR. Cygwin is the bane of this CI as it takes unnatural amounts of time :/. Having worked on the |
Sorry, something went wrong.
Fixes: #1887
Improve the guarding
ifcheck inGitConfigParser'sstring_decodefunction to safely handle empty strings and preventIndexErrors when accessing string elements.This resolves an IndexError in the
GitConfigParser's.read()method when the config file contains a quoted value ending with a new line.