GNU bug report logs -
#53808
29.0.50; ansi colorization process could block indefinetly on stray ESC char
Previous Next
Reported by: Ioannis Kappas <ioannis.kappas <at> gmail.com>
Date: Sat, 5 Feb 2022 20:53:02 UTC
Severity: normal
Found in version 29.0.50
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On Sat, Feb 5, 2022 at 9:56 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
>
> Ioannis Kappas <ioannis.kappas <at> 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.
This bug report was last modified 3 years and 106 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.