Skip to content

Commit

Permalink
Allow trailing dots in the domain name
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroSteiner committed Mar 25, 2024
1 parent c43f950 commit 9937ebb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/rex/socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def self.support_ipv6?
#
def self.is_name?(name)
return false if name.length > 253
name =~ MATCH_DNS_NAME ? (name =~ /\s/).nil? : false
name.delete_suffix('.') =~ MATCH_DNS_NAME ? (name =~ /\s/).nil? : false
end

#
Expand Down
15 changes: 12 additions & 3 deletions spec/rex/socket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,18 @@
end

context 'with a fully qualified domain name' do
let(:try) { "www.metasploit.com" }
it "should return true" do
expect(name).to eq true
context 'and a trailing dot' do
let(:try) { "www.metasploit.com." }
it "should return true" do
expect(name).to eq true
end
end

context 'and no trailing dot' do
let(:try) { "www.metasploit.com" }
it "should return true" do
expect(name).to eq true
end
end
end

Expand Down

0 comments on commit 9937ebb

Please sign in to comment.