git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv2] parse-options: report uncorrupted multi-byte options

From
Duy Nguyen <pclouds@gmail.com>
Date
Feb 12, 2013, 02:30 UTC
Message-ID
<CACsJy8DZy0_1RyeNtuobzABUD0rr6oE6RB=rXdqbG72SK4kNUw@mail.gmail.com>
In-Reply-To
<7va9rajn99.fsf@alter.siamese.dyndns.org>
On Tue, Feb 12, 2013 at 9:10 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
>> Similar cases:
>>
>> config.c:git_default_core_config() assumes core.commentchar is ascii.
>> We should catch and report non-ascii chars, or simply accept it as a
>> string.
>
> That one is just an uninterpreted byte.  core.commentString might be
> a nice extension to the concept, but it is an entirely different
> category.

My point is not to output broken utf-8 if we can. If someone accidentally puts a UTF-8 character in core.commentChar, it will produce broken utf-8 templates that editors might react, but hard to see by eye. Something like this may give sufficient protection:

diff --git a/config.c b/config.c
index aefd80b..b6f73e0 100644
--- a/config.c
+++ b/config.c
@@ -726,8 +726,11 @@ static int git_default_core_config(const char
*var, const char *value)
        if (!strcmp(var, "core.commentchar")) {
                const char *comment;
                int ret = git_config_string(&comment, var, value);
-               if (!ret)
+               if (!ret) {
+                       if (comment[1])
+                               return error("core.commentchar must be
one ASCII character");
                        comment_line_char = comment[0];
+               }
                return ret;
        }
-- 
Duy
Previous: Junio C Hamano
Message 6 of 6 in “[PATCHv2] parse-options: report uncorrupted multi-byte options”
  1. Erik Faye-LundFeb 11, 2013
  2. Junio C HamanoFeb 11, 2013
  3. Jeff KingFeb 12, 2013
  4. Duy NguyenFeb 12, 2013
  5. Junio C HamanoFeb 12, 2013
  6. Duy NguyenFeb 12, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.