X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fis_domain_name.rb;h=390a86894072202b23b8a6b50d269a57f0806c73;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hp=247db3b599e0254049befb5f1839d897d6168dd7;hpb=6963202b4b62c2816655ac9532521b018fdf83bd;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb index 247db3b59..390a86894 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb @@ -1,14 +1,21 @@ # # is_domain_name.rb # - module Puppet::Parser::Functions - newfunction(:is_domain_name, :type => :rvalue, :doc => <<-EOS -Returns true if the string passed to this function is a syntactically correct domain name. - EOS - ) do |arguments| + newfunction(:is_domain_name, :type => :rvalue, :doc => <<-DOC + @summary + **Deprecated:** Returns true if the string passed to this function is + a syntactically correct domain name. + + @return [Boolean] + Returns `true` or `false` - if (arguments.size != 1) then + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). + DOC + ) do |arguments| + + if arguments.size != 1 raise(Puppet::ParseError, "is_domain_name(): Wrong number of arguments given #{arguments.size} for 1") end @@ -18,9 +25,9 @@ Returns true if the string passed to this function is a syntactically correct do domain = arguments[0].dup # Limits (rfc1035, 3.1) - domain_max_length=255 - label_min_length=1 - label_max_length=63 + domain_max_length = 255 + label_min_length = 1 + label_max_length = 63 # Allow ".", it is the top level domain return true if domain == '.' @@ -34,7 +41,7 @@ Returns true if the string passed to this function is a syntactically correct do # 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) + return false if domain.include?('.') && !%r{\.[A-Za-z]+$}.match(domain) # Check each label in the domain labels = domain.split('.') @@ -43,10 +50,9 @@ Returns true if the string passed to this function is a syntactically correct do break if label.length > label_max_length break if label[-1..-1] == '-' break if label[0..0] == '-' - break unless /^[a-z\d-]+$/i.match(label) + break unless %r{^[a-z\d-]+$}i =~ label end return vlabels == labels - end end