ruby-changes:59530
From: aycabta <ko1@a...>
Date: Fri, 27 Dec 2019 16:03:02 +0900 (JST)
Subject: [ruby-changes:59530] 778634f778 (master): Drop an invalid char as UTF-8
https://git.ruby-lang.org/ruby.git/commit/?id=778634f778 From 778634f778a029476fb85463462848c0341f8e6b Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Fri, 27 Dec 2019 16:02:07 +0900 Subject: Drop an invalid char as UTF-8 diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 75af50a..3f6d781 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1091,6 +1091,11 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L1091 private def ed_insert(key) if key.instance_of?(String) + begin + key.encode(Encoding::UTF_8) + rescue Encoding::UndefinedConversionError + return + end width = Reline::Unicode.get_mbchar_width(key) if @cursor == @cursor_max @line += key @@ -1101,6 +1106,11 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L1106 @cursor += width @cursor_max += width else + begin + key.chr.encode(Encoding::UTF_8) + rescue Encoding::UndefinedConversionError + return + end if @cursor == @cursor_max @line += key.chr else -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/