[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 21:47:50 +0000 |
(sorry, I sent out the wrong patch, the correct one is
modified lisp/ansi-color.el
@@ -501,6 +501,20 @@ ansi-color-filter-apply
(setcar (cdr context) fragment))
(apply #'concat (nreverse result))))
+(defconst ansi-color--sgr-partial-regex
+ "\e\\(?:\\[\\|$\\)\\(?:[0-9]+;?\\)*"
+ "A regexp for locating the beginning of a partial SGR
+ sequence.")
+
+(defun ansi-color--sgr-fragment-pos (string start)
+ "Check if STRING ends with a partial SGR sequence and return
+its position or nil otherwise. Start looking in STRING at position START."
+ (save-match-data
+ (when (and (string-match ansi-color--sgr-partial-regex string start)
+ (or (= (match-end 0) 0)
+ (= (match-end 0) (length string))) )
+ (match-beginning 0))))
+
(defun ansi-color-apply (string)
"Translates SGR control sequences into text properties.
Delete all other control sequences without processing them.
@@ -549,8 +563,8 @@ ansi-color-apply
(put-text-property start (length string)
'font-lock-face face string))
;; save context, add the remainder of the string to the result
- (if (string-match "\033" string start)
- (let ((pos (match-beginning 0)))
+ (if-let ((pos (ansi-color--sgr-fragment-pos string start)))
+ (progn
(setcar (cdr context) (substring string pos))
(push (substring string start pos) result))
(push (substring string start) result))
)
- bug#53808: 29.0.50; ansi colorization process could block indefinetly on stray ESC char, Ioannis Kappas, 2022/02/05
- bug#53808: 29.0.50; ansi colorization process could block indefinetly on stray ESC char, Ioannis Kappas, 2022/02/05
- bug#53808: 29.0.50; ansi colorization process could block indefinetly on stray ESC char,
Ioannis Kappas <=
- bug#53808: 29.0.50; ansi colorization process could block indefinetly on stray ESC char, Lars Ingebrigtsen, 2022/02/05
- bug#53808: 29.0.50; ansi colorization process could block indefinetly on stray ESC char, Ioannis Kappas, 2022/02/05
- bug#53808: 29.0.50; ansi colorization process could block indefinetly on stray ESC char, miha, 2022/02/06
- bug#53808: 29.0.50; ansi colorization process could block indefinetly on stray ESC char, Lars Ingebrigtsen, 2022/02/06
- bug#53808: 29.0.50; ansi colorization process could block indefinetly on stray ESC char, Ioannis Kappas, 2022/02/07
- bug#53808: 29.0.50; ansi colorization process could block indefinetly on stray ESC char, miha, 2022/02/07