unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ioannis Kappas <ioannis.kappas@gmail.com>
To: 53808@debbugs.gnu.org
Subject: bug#53808: 29.0.50; ansi colorization process could block indefinetly on stray ESC char
Date: Sat, 5 Feb 2022 20:52:25 +0000	[thread overview]
Message-ID: <CAMRHuGAcY60X4cTMXRQCcH2v=KU2mi=7oJi0Daz4S6MVRWKHOA@mail.gmail.com> (raw)

Hi,

there appears to be an issue with `ansi-color-apply' that a stray ESC
control character in the input string can block the colorization process

(with-temp-buffer (ansi-color-apply "a\ebc"))
;; => "a"

(with-temp-buffer (concat (ansi-color-apply "a\ebc") (ansi-color-apply "xyz")))
;; => "a"

The process is blocked at character a the rest are never printed. It
can only resume when a CSI
seq (i.e. one starting with ESC [) appears in the stream

(with-temp-buffer (concat (ansi-color-apply "ab\ec") (ansi-color-apply
"x\e[yz")))
;; => "ab^[cxz"

or, using a valid SGR as an example

(with-temp-buffer (concat (ansi-color-apply "ab\ec") (ansi-color-apply
"x\e[3myz")))
;; => #("ab^[cxyz" 5 7
;;      (font-lock-face italic))


This behavior can pose serious problems to applications which support
ansi colorisation of their output streams, but otherwise treat ESC as
any other control character (e.g. REPLs colorizing their output with
ansi-color but they also like to display any other character). Their
output might be blocked indefinitely when an ESC character appears in
their output.

My expectation is that a character sequence starting with ESC which is
not being part of an SGR sequence, should be output immediately,
rather than treated as a potential SGR sequence (which by definition
it can never be) blocking further processing.

e.g.
(with-temp-buffer (ansi-color-apply "a\ebc"))
;; => "a^[bc"

Analysis to follow.

Thanks

In GNU Emacs 29.0.50 (build 1, x86_64-w64-mingw32)
Repository revision: 3a8e140ad115633791d057bd10998d80c33e6dc7
Repository branch: master
Windowing system distributor 'Microsoft Corp.', version 10





             reply	other threads:[~2022-02-05 20:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-05 20:52 Ioannis Kappas [this message]
2022-02-05 21:00 ` bug#53808: 29.0.50; ansi colorization process could block indefinetly on stray ESC char Ioannis Kappas
2022-02-05 21:47   ` Ioannis Kappas
2022-02-05 21:56   ` Lars Ingebrigtsen
2022-02-05 22:05     ` Ioannis Kappas
2022-02-06 20:36       ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-06 22:55         ` Lars Ingebrigtsen
2022-02-07  7:51         ` Ioannis Kappas
2022-02-07 11:42           ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='CAMRHuGAcY60X4cTMXRQCcH2v=KU2mi=7oJi0Daz4S6MVRWKHOA@mail.gmail.com' \
    --to=ioannis.kappas@gmail.com \
    --cc=53808@debbugs.gnu.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).