From: Ioannis Kappas <ioannis.kappas@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 53808@debbugs.gnu.org, "Miha Rihtaršič" <miha@kamnitnik.top>
Subject: bug#53808: 29.0.50; ansi colorization process could block indefinetly on stray ESC char
Date: Sat, 5 Feb 2022 22:05:05 +0000 [thread overview]
Message-ID: <CAMRHuGB=UdG+zeRiKoL3DzsgdJPXc_FX6XkLpDvU=mY5c8aVzQ@mail.gmail.com> (raw)
In-Reply-To: <87fsoxasfs.fsf@gnus.org>
On Sat, Feb 5, 2022 at 9:56 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:
>
> Ioannis Kappas <ioannis.kappas@gmail.com> writes:
>
> > A solution (open to discussion) could be to identify a partial SGR
> > fragment based on its actual specification rather than only starting
> > with the ESC char:
>
> Hm... what happens if the ESC arrives in one chunk and then the rest of
> the SGR sequence in the next chunk?
It is handled correctly as expected if the concatenated sequence is an
SGR, it is output as such, i.e. all
test/lisp/ansi-color-tests.el:ansi-color-incomplete-sequences-test
pass still pass.
Here is the list of unit tests showing of what I consider correct
handling of non SGR sequences I have came up with thus far
(ert-deftest ansi-color-context-non-sgr ()
(with-temp-buffer
(let ((text (ansi-color-apply "\e[33mHello World\e[0m")))
(should (string= "Hello World" text))
(should (equal (get-char-property 0 'font-lock-face text)
'(:foreground "yellow3")))
))
(with-temp-buffer
(let ((pretext (ansi-color-apply "5"))
(text (ansi-color-apply "\e[33mHello World\e[0m")))
(should (string= "Hello World" text))
(should (equal (get-char-property 0 'font-lock-face text)
'(:foreground "yellow3")))
))
(with-temp-buffer
(let ((pretext (ansi-color-apply "\e"))
(text (ansi-color-apply "\e[33mHello World\e[0m")))
(should (string= "\eHello World" text))
(should (equal (get-char-property 1 'font-lock-face text)
'(:foreground "yellow3")))
))
(with-temp-buffer
(let ((pretext (ansi-color-apply "\e["))
(text (ansi-color-apply "\e[33mHello World\e[0m")))
(should (string= "\e[Hello World" text))
(should (equal (get-char-property 2 'font-lock-face text)
'(:foreground "yellow3")))
))
(with-temp-buffer
(let ((pretext (ansi-color-apply "\e[33"))
(text (ansi-color-apply "mHello World\e[0m")))
(should (string= "Hello World" text))
(should (equal (get-char-property 2 'font-lock-face text)
'(:foreground "yellow3")))
))
(with-temp-buffer
(let ((pretext (ansi-color-apply "\e[33m"))
(text (ansi-color-apply "Hello World\e[0m")))
(should (string= "Hello World" text))
(should (equal (get-char-property 2 'font-lock-face text)
'(:foreground "yellow3")))
))
(with-temp-buffer
(let ((pretext (ansi-color-apply "\e[33;1"))
(text (ansi-color-apply "mHello World\e[0m")))
(should (string= "Hello World" text))
(should (equal (get-char-property 2 'font-lock-face text)
'(ansi-color-bold (:foreground "yellow3"))))
))
(with-temp-buffer
(let ((pretext (ansi-color-apply "\e[33;"))
(text (ansi-color-apply "1mHello World\e[0m")))
(should (string= "Hello World" text))
(should (equal (get-char-property 2 'font-lock-face text)
'(ansi-color-bold (:foreground "yellow3"))))
))
)
> (Miha has done work in this area recently; added to the CCs.)
Looking forward to his feedback :) it is because of his work I've
decided to raise this against 29 instead of the 28 branch.
next prev parent reply other threads:[~2022-02-05 22:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-05 20:52 bug#53808: 29.0.50; ansi colorization process could block indefinetly on stray ESC char Ioannis Kappas
2022-02-05 21:00 ` Ioannis Kappas
2022-02-05 21:47 ` Ioannis Kappas
2022-02-05 21:56 ` Lars Ingebrigtsen
2022-02-05 22:05 ` Ioannis Kappas [this message]
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='CAMRHuGB=UdG+zeRiKoL3DzsgdJPXc_FX6XkLpDvU=mY5c8aVzQ@mail.gmail.com' \
--to=ioannis.kappas@gmail.com \
--cc=53808@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=miha@kamnitnik.top \
/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).