diff options
author | Miklós Fazekas <mfazekas@szemafor.com> | 2021-08-06 11:47:03 +0200 |
---|---|---|
committer | Miklós Fazekas <mfazekas@szemafor.com> | 2021-08-06 11:47:03 +0200 |
commit | 58c4cbca9369b8d341b2fe2ad9ded2490ddf3d69 (patch) | |
tree | 909f48974903da77e505c4fec31726650a11c565 /lib | |
parent | 5d87ccae454b9c8867478788f97c885ac8188ddc (diff) | |
download | net-ssh-58c4cbca9369b8d341b2fe2ad9ded2490ddf3d69.tar.gz |
Allow single asterisk in known hosts and asterisk should match mutliple dots
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net/ssh/known_hosts.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/net/ssh/known_hosts.rb b/lib/net/ssh/known_hosts.rb index b52bc6a..eb7d7a7 100644 --- a/lib/net/ssh/known_hosts.rb +++ b/lib/net/ssh/known_hosts.rb @@ -223,11 +223,11 @@ module Net def match(host, pattern) if pattern.include?('*') || pattern.include?('?') # see man 8 sshd for pattern details - pattern_regexp = pattern.split('*').map do |x| - x.split('?').map do |y| + pattern_regexp = pattern.split('*', -1).map do |x| + x.split('?', -1).map do |y| Regexp.escape(y) end.join('.') - end.join('[^.]*') + end.join('.*') host =~ Regexp.new("\\A#{pattern_regexp}\\z") else |