From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ioannis Kappas Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <87fsoxasfs.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23270"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 53808@debbugs.gnu.org, Miha =?UTF-8?Q?Rihtar=C5=A1i=C4=8D?= To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 05 23:06:10 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nGTC5-0005ny-EI for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 05 Feb 2022 23:06:09 +0100 Original-Received: from localhost ([::1]:33320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGTC3-0001um-MN for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 05 Feb 2022 17:06:07 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:57962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGTBy-0001ue-JZ for bug-gnu-emacs@gnu.org; Sat, 05 Feb 2022 17:06:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41878) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGTBy-0008JM-AJ for bug-gnu-emacs@gnu.org; Sat, 05 Feb 2022 17:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nGTBy-00032M-20 for bug-gnu-emacs@gnu.org; Sat, 05 Feb 2022 17:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ioannis Kappas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 05 Feb 2022 22:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53808 X-GNU-PR-Package: emacs Original-Received: via spool by 53808-submit@debbugs.gnu.org id=B53808.164409872311629 (code B ref 53808); Sat, 05 Feb 2022 22:06:02 +0000 Original-Received: (at 53808) by debbugs.gnu.org; 5 Feb 2022 22:05:23 +0000 Original-Received: from localhost ([127.0.0.1]:35775 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGTBK-00031V-Nc for submit@debbugs.gnu.org; Sat, 05 Feb 2022 17:05:23 -0500 Original-Received: from mail-oi1-f177.google.com ([209.85.167.177]:44616) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGTBI-00031H-Qb for 53808@debbugs.gnu.org; Sat, 05 Feb 2022 17:05:21 -0500 Original-Received: by mail-oi1-f177.google.com with SMTP id 4so12868954oil.11 for <53808@debbugs.gnu.org>; Sat, 05 Feb 2022 14:05:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Jd2ZnpT7OzPE6ZYC0lLUZBmQgnbGZypsS80pqRi5nQI=; b=HvfWxGbvGsl83lOLGtrqw7UNQmF+IcnXPTSXPz1GXOifW2LhVmDqP2lhQVuhzsTMG8 jyIWX09v14zmbjJQ6nFKJxuyzzwBXQuA6k9d34mWMwtBCCJ6dc91vCSXR+YsumxOHQmS 6PAPdbFsiAAGuFRVV/yv+V/6H+0nhW8GWH/T5woYE2BZsafwZtAjUY0GJx0FblT4L8LV 6/a1IBo0PoACyH4oAr4453fiGPBh7+ezfEQ177D6M24Gqe0YECI4nqtTjjLgFSaXcqm7 ur95sNGNDgWkxA+oJBY5JdjbGpWzOwUvSVSvu+b1RChrcKxdlpiZdp4LPYKINX3zZruE x2lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Jd2ZnpT7OzPE6ZYC0lLUZBmQgnbGZypsS80pqRi5nQI=; b=NN3qg2AaaK8glSHOGBo41MNHTv5XfdrxI9Gur8HPe5aVJNoEmlRIHJKYf/trB8mEqM 87SnByaW//qbUULwNvepw4PyFez2p/BcNLCf0KCR5kHleOaTa43+KBMpYTx+Z07nnLlr BfEn2Y8JNuvL/3eK8Nif63RhiO9KaQKuDhMiLtRsgRnQrW8DiSHOtTyWFuSj/1NhtOrV aXzLhHGUHojHGp2DHsyXQJjtlJ8Q50kJ5c5ZwCV9W9a3Jf5qjRJsUx0osjPUfWhLSB0G UB1nB9qHEhLdTLV8AT6Pzp/XzM2zUj6PSUAronDnoEHTgTE7OraXbpCFf95XI5zZW18f npmQ== X-Gm-Message-State: AOAM533M6ROuzwNHMbXNwxZQqthF7MF7+qZ+DDzzc/jNeTPpLQgFIiZo sWOMJf1l7twiJZg2THi1idly3JVU2G6S1gaiKO8= X-Google-Smtp-Source: ABdhPJz+5TRJ3oW/3AmXE7WICIq/YkzgtIXqIuvlN91fWW3zbIqwEDvwgPj+mgveYIRX2xjSKS1Y3zV9/ULZQVmikTM= X-Received: by 2002:a05:6808:2228:: with SMTP id bd40mr2414994oib.335.1644098715166; Sat, 05 Feb 2022 14:05:15 -0800 (PST) In-Reply-To: <87fsoxasfs.fsf@gnus.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:226099 Archived-At: On Sat, Feb 5, 2022 at 9:56 PM Lars Ingebrigtsen wrote: > > Ioannis Kappas 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.