bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25222: Incorrect indices in ansi-color (227e996946d4629fa8f6d665564a


From: Clément Pit--Claudel
Subject: bug#25222: Incorrect indices in ansi-color (227e996946d4629fa8f6d665564a37668290c87f, new in Emacs 25)
Date: Sun, 18 Dec 2016 11:07:09 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

Package: emacs
X-Debbugs-CC: Daniel Colascione <address@hidden>

Hi all,

The following snippet throws an out-of-bounds error on master and in Emacs 25.:

(ansi-color-filter-apply
 (base64-decode-string 
"UHl0aG9uIDIuNy4xMiAoZGVmYXVsdCwgTm92IDE5IDIwMTYsIDA2OjQ4OjEwKSAKVHlwZSAiY29w
eXJpZ2h0IiwgImNyZWRpdHMiIG9yICJsaWNlbnNlIiBmb3IgbW9yZSBpbmZvcm1hdGlvbi4KCklQ
eXRob24gNS4xLjAgLS0gQW4gZW5oYW5jZWQgSW50ZXJhY3RpdmUgUHl0aG9uLgo/ICAgICAgICAg
LT4gSW50cm9kdWN0aW9uIGFuZCBvdmVydmlldyBvZiBJUHl0aG9uJ3MgZmVhdHVyZXMuCiVxdWlj
a3JlZiAtPiBRdWljayByZWZlcmVuY2UuCmhlbHAgICAgICAtPiBQeXRob24ncyBvd24gaGVscCBz
eXN0ZW0uCm9iamVjdD8gICAtPiBEZXRhaWxzIGFib3V0ICdvYmplY3QnLCB1c2UgJ29iamVjdD8/
JyBmb3IgZXh0cmEgZGV0YWlscy4KChtbPzFsG1s2bhtbPzIwMDRoG1s/MjVsG1s/N2wbWzBtDRtb
MG0bW0oNG1s/MTJsG1s/MjVoG1tKG1swbRtbPzIwMDRsG1s2bhtbPzIwMDRoG1s/MjVsG1s/N2wb
WzBtG1swbRtbShtbMDszODs1OzI4bUluIFsbWzA7Mzg7NTsxMDsxbTEbWzA7Mzg7NTsyOG1dOiAb
WzhEG1s4QxtbPzEybBtbPzI1aA=="))

This is caused by the following snippet:

    ;; 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)))
    ;; save context, add the remainder of the string to the result
    (let (fragment)
      (if (string-match "\033" string start)

(the error happens on the last line).  The "unrecognized escape sequences" part 
does not adjust the "start" variable.

Maybe that section could just be moved up (before "find the next escape 
sequence")? Daniel, what do you think?

Cheers,
Clément.


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]