Skip to content

(MODULES-1670) Do not match dotted-quad IP address as domain name #404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/puppet/parser/functions/is_domain_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ module Puppet::Parser::Functions
return false if domain.empty?
return false if domain.length > domain_max_length

# The top level domain must be alphabetic if there are multiple labels.
# See rfc1123, 2.1
return false if domain.include? '.' and not /\.[A-Za-z]+$/.match(domain)

# Check each label in the domain
labels = domain.split('.')
vlabels = labels.each do |label|
Expand Down
10 changes: 10 additions & 0 deletions spec/functions/is_domain_name_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,14 @@
result = scope.function_is_domain_name(["my.domain.name".freeze])
expect(result).to(be_truthy)
end

it "should return false if top-level domain is not entirely alphabetic" do
result = scope.function_is_domain_name(["kiwi.2bar"])
expect(result).to(be_falsey)
end

it "should return false if domain name has the dotted-decimal form, e.g. an IPv4 address" do
result = scope.function_is_domain_name(["192.168.1.1"])
expect(result).to(be_falsey)
end
end