diff --git a/lib/reline/terminfo.rb b/lib/reline/terminfo.rb index 95ff082172..b053ba82c4 100644 --- a/lib/reline/terminfo.rb +++ b/lib/reline/terminfo.rb @@ -121,6 +121,7 @@ module Reline::Terminfo end def self.tigetstr(capname) + raise TerminfoError, "capname is not String: #{capname.inspect}" unless capname.is_a?(String) capability = @tigetstr.(capname) case capability.to_i when 0, -1 @@ -138,6 +139,7 @@ module Reline::Terminfo end def self.tigetflag(capname) + raise TerminfoError, "capname is not String: #{capname.inspect}" unless capname.is_a?(String) flag = @tigetflag.(capname).to_i case flag when -1 @@ -149,6 +151,7 @@ module Reline::Terminfo end def self.tigetnum(capname) + raise TerminfoError, "capname is not String: #{capname.inspect}" unless capname.is_a?(String) num = @tigetnum.(capname).to_i case num when -2 diff --git a/test/reline/test_terminfo.rb b/test/reline/test_terminfo.rb index b969da1397..dda9b32495 100644 --- a/test/reline/test_terminfo.rb +++ b/test/reline/test_terminfo.rb @@ -14,6 +14,7 @@ class Reline::Terminfo::Test < Reline::TestCase def test_tigetstr_with_error assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetstr('unknown') } + assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetstr(nil) } end def test_tiparm @@ -43,6 +44,7 @@ class Reline::Terminfo::Test < Reline::TestCase def test_tigetflag_with_error assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetflag('cuu') } assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetflag('unknown') } + assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetflag(nil) } end def test_tigetnum @@ -54,5 +56,6 @@ class Reline::Terminfo::Test < Reline::TestCase def test_tigetnum_with_error assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetnum('cuu') } assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetnum('unknown') } + assert_raise(Reline::Terminfo::TerminfoError) { Reline::Terminfo.tigetnum(nil) } end end if Reline::Terminfo.enabled?