File tree Expand file tree Collapse file tree
lib/puppet/parser/functions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ module Puppet::Parser::Functions
3333 return false if domain . empty?
3434 return false if domain . length > domain_max_length
3535
36+ # The top level domain must be alphabetic if there are multiple labels.
37+ # See rfc1123, 2.1
38+ return false if domain . include? '.' and not /\. [A-Za-z]+$/ . match ( domain )
39+
3640 # Check each label in the domain
3741 labels = domain . split ( '.' )
3842 vlabels = labels . each do |label |
Original file line number Diff line number Diff line change 6868 result = scope . function_is_domain_name ( [ "my.domain.name" . freeze ] )
6969 expect ( result ) . to ( be_truthy )
7070 end
71+
72+ it "should return false if top-level domain is not entirely alphabetic" do
73+ result = scope . function_is_domain_name ( [ "kiwi.2bar" ] )
74+ expect ( result ) . to ( be_falsey )
75+ end
76+
77+ it "should return false if domain name has the dotted-decimal form, e.g. an IPv4 address" do
78+ result = scope . function_is_domain_name ( [ "192.168.1.1" ] )
79+ expect ( result ) . to ( be_falsey )
80+ end
7181end
You can’t perform that action at this time.
0 commit comments