diff options
author | Mark Delk <jethrodaniel@gmail.com> | 2021-04-13 21:23:07 -0500 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2021-06-21 17:58:48 +0900 |
commit | a049dfd10a3b9ae24a1822e807398422e87d142f (patch) | |
tree | db6c7545f97aa78a0a4d934ac5d39f9839a07153 /lib/reline | |
parent | c2f30aaade9abe103a727a5440325baff58f66ba (diff) |
[ruby/reline] ensure reline's encoding is used when reading inputrc character values
This change ensures we use `Reline::IOGate`'s `encoding` when converting
characters from their integer values.
This fixes an issue that may occur if you have UTF characters in your
`.inputrc`, but your default encoding isn't set.
For example:
```
> 127864.ord.chr
RangeError: 127864 out of char range
from (pry):1:in `chr'
> Reline::IOGate.encoding
=> #<Encoding:UTF-8>
> 127864.ord.chr(Reline::IOGate.encoding)
=> "🍸"
```
https://github.com/ruby/reline/commit/cf372fc0fc
Diffstat (limited to 'lib/reline')
-rw-r--r-- | lib/reline/config.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/reline/config.rb b/lib/reline/config.rb index 9689c8f51d..dd81a23ea7 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -292,11 +292,8 @@ class Reline::Config end def retrieve_string(str) - if str =~ /\A"(.*)"\z/ - parse_keyseq($1).map(&:chr).join - else - parse_keyseq(str).map(&:chr).join - end + str = $1 if str =~ /\A"(.*)"\z/ + parse_keyseq(str).map { |c| c.chr(Reline::IOGate.encoding) }.join end def bind_key(key, func_name) |