diff options
author | tomoya ishida <[email protected]> | 2024-10-02 02:01:31 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-10-01 17:01:38 +0000 |
commit | e320da60976f6818c8667afb98fe88142c3073d2 (patch) | |
tree | 3b056188af6c69387799b656a1e6aebf972255d2 /lib/reline/history.rb | |
parent | ec230ac6432ea89f1ee53d82a62337d4883dc83a (diff) |
[ruby/reline] Fix Reline crash with invalid encoding history
(https://github.com/ruby/reline/pull/751)
https://github.com/ruby/reline/commit/e9d4b37e34
Diffstat (limited to 'lib/reline/history.rb')
-rw-r--r-- | lib/reline/history.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/reline/history.rb b/lib/reline/history.rb index 3f3b65fea6..47c68ba774 100644 --- a/lib/reline/history.rb +++ b/lib/reline/history.rb @@ -19,7 +19,7 @@ class Reline::History < Array def []=(index, val) index = check_index(index) - super(index, String.new(val, encoding: Reline.encoding_system_needs)) + super(index, Reline::Unicode.safe_encode(val, Reline.encoding_system_needs)) end def concat(*val) @@ -45,7 +45,7 @@ class Reline::History < Array end end super(*(val.map{ |v| - String.new(v, encoding: Reline.encoding_system_needs) + Reline::Unicode.safe_encode(v, Reline.encoding_system_needs) })) end @@ -56,7 +56,7 @@ class Reline::History < Array if @config.history_size.positive? shift if size + 1 > @config.history_size end - super(String.new(val, encoding: Reline.encoding_system_needs)) + super(Reline::Unicode.safe_encode(val, Reline.encoding_system_needs)) end private def check_index(index) |