[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#53808: 29.0.50; ansi colorization process could block indefinetly on
From: |
Ioannis Kappas |
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 |
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.