Git development
 help / color / mirror / Atom feed
From: Mantas <grawity@nullroute.lt>
To: Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, "Mantas Mikulėnas" <grawity@gmail.com>
Subject: Re: [PATCH] sideband: allow ANSI SGR with colon-separated subfields
Date: Tue, 7 Jul 2026 22:01:50 +0300	[thread overview]
Message-ID: <897cefe6-18f1-4c53-bf2a-dd91052e70e5@nullroute.lt> (raw)
In-Reply-To: <xmqq4iia4q8t.fsf@gitster.g>

On 2026-07-07 21:19, Junio C Hamano wrote:
> A need for fix-up like this does makes me doubt out decision to go
> with whitelisting very narrow cases that are known to be OK (and
> finding that the cases were too narrow and we need to extend),
> instead of rejecting known-bad cases, by the way.

For the SGR sequence (CSI ... m) AFAIK there are no other value types 
besides what this patch adds (i.e. colon-separated decimal 
subparameters), so the filter will now include all possible cases. It 
already isn't picky about individual values.

As for everything else (that is escape sequences in general), I'd say 
there are way too many "bad" cases – which can toggle terminal modes, 
display images, send notifications, copy to clipboard, move windows 
around... which a remote "status text" output has no reason to include – 
and basically zero "good" cases. Though the code already disallows the 
majority of harmful cases by only accepting those starting with CSI 
("ESC [").

In fact I might personally go further and disallow even all of the 
cursor movement sequences and leave only SGR and EL (clear line). I can 
imagine a use-case for free cursor movement (parallel progress bars like 
in Arch's pacman?) but it practically requires the sender to know 
terminal dimensions to be useful, so IMO is entirely out of scope for 
sideband status output.

(Progress bar for example (OSC 9;4;n ST) might be useful, but IMO it 
should be generated client-side, with the server instead having some way 
to report an integer percentage through the protocol. In theory the 
"hyperlink" sequence (OSC 8 ; ... ST) could also be useful to send as 
part of status text, but I'd personally disallow that as well, given all 
the reporting last time someone discovered it was possible to link to a 
file:// URL.)


> Thanks.
>
>> Ciao,
>> Johannes
>>
>>> Signed-off-by: Mantas Mikulėnas <grawity@gmail.com>
>>> ---
>>>   sideband.c | 6 +++++-
>>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/sideband.c b/sideband.c
>>> index 04282a568e..6cf70ef6f6 100644
>>> --- a/sideband.c
>>> +++ b/sideband.c
>>> @@ -163,6 +163,10 @@ static int handle_ansi_sequence(struct strbuf *dest, const char *src, int n)
>>>   	 *
>>>   	 * ESC [ [<n> [; <n>]*] m
>>>   	 *
>>> +	 * where <n> can be either zero-length, or a decimal number, or a
>>> +	 * series of decimal numbers separated by a colon (for 256-color or
>>> +	 * true-color codes).
>>> +	 *
>>>   	 * These are part of the Select Graphic Rendition sequences which
>>>   	 * contain more than just color sequences, for more details see
>>>   	 * https://en.wikipedia.org/wiki/ANSI_escape_code#SGR.
>>> @@ -210,7 +214,7 @@ static int handle_ansi_sequence(struct strbuf *dest, const char *src, int n)
>>>   			strbuf_add(dest, src, i + 1);
>>>   			return i;
>>>   		}
>>> -		if (!isdigit(src[i]) && src[i] != ';')
>>> +		if (!isdigit(src[i]) && src[i] != ':' && src[i] != ';')
>>>   			break;
>>>   	}
>>>   
>>> -- 
>>> 2.54.0
>>>
>>>

      reply	other threads:[~2026-07-07 19:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13  7:08 [PATCH] sideband: allow ANSI SGR with colon-separated subfields grawity
2026-07-07 11:45 ` Johannes Schindelin
2026-07-07 18:19   ` Junio C Hamano
2026-07-07 19:01     ` Mantas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=897cefe6-18f1-4c53-bf2a-dd91052e70e5@nullroute.lt \
    --to=grawity@nullroute.lt \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=grawity@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox