GNU bug report logs - #24223
25.1; Error in ansi-color-filter-apply when control sequences are dropped

Previous Next

Package: emacs;

Reported by: Ivan Andrus <darthandrus <at> gmail.com>

Date: Sun, 14 Aug 2016 05:44:02 UTC

Severity: normal

Tags: fixed

Merged with 21381, 24189, 25222, 25306, 25363, 25416

Found in versions 24.5, 25.1, 25.1.50, 25.1.91

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ivan Andrus <darthandrus <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Cc: Daniel Colascione <dancol <at> dancol.org>
Subject: 25.1;
 Error in ansi-color-filter-apply when control sequences are dropped
Date: Sat, 13 Aug 2016 23:43:20 -0600
In `ansi-color-filter-apply' the block "eliminate unrecognized escape
sequences" occurs after the "find the next escape sequence" block.  This
is problematic because the variable start is set in the "next sequence"
block and used in the "save context, add the remainder of the string to
the result" block.  However, dropping control sequences with
`ansi-color-drop-regexp' can cause the string to shorten and start to
point past the end of the string.

I merely swapped the order of the first two blocks mentioned and was
able to get past the error.  But there are likely other places that need
to be fixed as well.

I have commit access, and can make the change (as well as tracking down
other places where it might be necessary), but I would like some
feedback on whether this is the right way solve it.  Presumably there
was a reason escape sequences were dropped after start was set up.

-Ivan

diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el
index 788a7bd..7cea2d9 100644
--- a/lisp/ansi-color.el
+++ b/lisp/ansi-color.el
@@ -258,14 +258,14 @@ ansi-color-filter-apply
     (if (cadr ansi-color-context)
         (setq string (concat (cadr ansi-color-context) string)
               ansi-color-context nil))
-    ;; find the next escape sequence
-    (while (setq end (string-match ansi-color-regexp string start))
-      (setq result (concat result (substring string start end))
-            start (match-end 0)))
     ;; eliminate unrecognized escape sequences
     (while (string-match ansi-color-drop-regexp string)
       (setq string
             (replace-match "" nil nil string)))
+    ;; find the next escape sequence
+    (while (setq end (string-match ansi-color-regexp string start))
+      (setq result (concat result (substring string start end))
+            start (match-end 0)))
     ;; save context, add the remainder of the string to the result
     (let (fragment)
       (if (string-match "\033" string start)




In GNU Emacs 25.1.2 (x86_64-apple-darwin15.5.0, NS appkit-1404.47 Version 10.11.6 (Build 15G31))
 of 2016-08-04 built on iandrus-osx
Repository revision: 784291b06c4e4fe52f4c1aa15bc99874abc517c4
Windowing system distributor 'Apple', version 10.3.1404
Configured using:
 'configure --with-ns --with-modules
 PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig'

Configured features:
JPEG RSVG IMAGEMAGICK DBUS NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS NS MODULES

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix




This bug report was last modified 8 years and 10 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.