unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 29918@debbugs.gnu.org, gazally@runbox.com, larsi@gnus.org
Subject: bug#29918: 26.0.90; serial-term error in process filter
Date: Thu, 18 Jul 2019 07:22:10 -0400	[thread overview]
Message-ID: <874l3jzixp.fsf@gmail.com> (raw)
In-Reply-To: <83pnm7ybmf.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 18 Jul 2019 11:45:28 +0300")

[-- Attachment #1: Type: text/plain, Size: 426 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> there is a possibility it prevents correct decoding in case the
>> terminal receives a utf-8 character in single byte chunks (though
>> I'm not sure if it's even valid for a program to emit single bytes
>> like that).
>
> I agree.

I thought of limiting partial to 4, to avoid this possibility, since
utf-8 characters can be 4 bytes at most (not sure about other encodings
though).  


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1506 bytes --]

From bad839ca47ac58bd4967b95f447a596940e832f1 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Wed, 17 Jul 2019 07:20:20 -0400
Subject: [PATCH] Handle completely undecoded input in term (Bug#29918)

* lisp/term.el (term-emulate-terminal): Avoid errors if the whole
decoded string is eight-bit characters.  Accumulate at most 4
undecoded bytes.
---
 lisp/term.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/term.el b/lisp/term.el
index cbef68dc0a..2fdd3253ec 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -2900,9 +2900,11 @@ term-emulate-terminal
                           ;; next time.
                           (when (= funny str-length)
                             (let ((partial 0))
-                              (while (eq (char-charset (aref decoded-substring
-                                                             (- count 1 partial)))
-                                         'eight-bit)
+                              (while (and (< partial count)
+                                          (< partial 4)
+                                          (eq (char-charset (aref decoded-substring
+                                                                  (- count 1 partial)))
+                                              'eight-bit))
                                 (cl-incf partial))
                               (when (> partial 0)
                                 (setq term-terminal-undecoded-bytes
-- 
2.11.0


  reply	other threads:[~2019-07-18 11:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-31 20:57 bug#29918: 26.0.90; serial-term error in process filter Gemini Lasswell
2019-07-14 17:52 ` Lars Ingebrigtsen
2019-07-15 21:45   ` Gemini Lasswell
2019-07-17 10:58     ` Lars Ingebrigtsen
2019-07-17 11:36       ` Noam Postavsky
2019-07-18  8:45         ` Eli Zaretskii
2019-07-18 11:22           ` Noam Postavsky [this message]
2019-07-18 11:33             ` Eli Zaretskii
2019-07-19  0:15               ` Noam Postavsky
2019-07-20 12:49                 ` Gemini Lasswell
2019-07-21  2:32                   ` Noam Postavsky
2019-07-21 13:49               ` Stefan Monnier
2019-07-21 14:38                 ` Eli Zaretskii
2019-07-21 14:45                   ` Lars Ingebrigtsen
2019-07-21 14:47                     ` Eli Zaretskii
2019-07-21 13:52             ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874l3jzixp.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=29918@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=gazally@runbox.com \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).