FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix config parsing for multiline with multiple quoted comment chars by basile-henry · Pull Request #6043 · libgit2/libgit2 · GitHub

Fix config parsing for multiline with multiple quoted comment chars - #6043

Merged
ethomson merged 2 commits into
libgit2:mainfrom
basile-henry:config-multiline-comment-chars
Sep 14, 2021
Merged

ethomson merged 2 commits into
libgit2:mainfrom
basile-henry:config-multiline-comment-chars

Conversation

Copy link
Copy Markdown
Contributor

Fixes #6019

The issue this PR fixes happened when parsing a git config with the following:

  • A multiline variable
  • Multiple quoted comment characters (on separate lines)

NB: comment characters (';' or '#') need to be quoted in order for them to be part of a string, otherwise they indicate the start of a comment. Comments are surprisingly permitted in the middle of a multiline variable.

I have added a small test that showcases the issue and then fixed it in a subsequent commit.
The fix is simply to keep the count of quotes in the multiline as an int instead of making it a bool before passing it to the strip_comments function. This seems to work just fine and all the tests now pass. I do wonder what was intended by the boolean "casting" 🤔

This tests parsing a multiline string containing multiple quoted comment
chars. See libgit2#6019
The strip_comments function uses the count of quotes to know if a
comment char (';' or '#') is the start of a comment or part of the
multiline as a string.
Unfortunately converting the count of quotes from previous lines to a
boolean meant that it would only work as expected in some cases
(0 quotes or an odd number of quotes).

Copy link
Copy Markdown
Member

I do wonder what was intended by the boolean "casting" 🤔

I do, too!

Thanks, @basile-henry!

ethomson merged commit 1f6263b into libgit2:main Sep 14, 2021
basile-henry deleted the config-multiline-comment-chars branch September 15, 2021 07:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config parsing can break on multiline with multiple quotes with multiple lines

2 participants


Back | FazBrowse Home | New Git URL