]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
(MODULES-1771) Don't modify input to is_domain_name()
authorSean Millichamp <sean.millichamp@secure-24.com>
Sat, 14 Feb 2015 15:46:34 +0000 (10:46 -0500)
committerSean Millichamp <sean.millichamp@secure-24.com>
Sat, 14 Feb 2015 15:49:26 +0000 (10:49 -0500)
Fix is_domain_name() so it dup's its incoming argument
to avoid changing the original with a later chomp!

lib/puppet/parser/functions/is_domain_name.rb
spec/functions/is_domain_name_spec.rb

index b3fee965a0bee88a8497e32d7a6166ba63fb1c24..24cc2085fb832eb101554480d46d99f679d45f46 100644 (file)
@@ -13,7 +13,7 @@ Returns true if the string passed to this function is a syntactically correct do
         "given #{arguments.size} for 1")
     end
 
-    domain = arguments[0]
+    domain = arguments[0].dup
 
     # Limits (rfc1035, 3.1)
     domain_max_length=255
index 4d05f5cdc58d5858ff696759612ea012d642eb92..5ab8369c07d3ce20a283233eb5a94709496ca74d 100755 (executable)
@@ -61,4 +61,11 @@ describe "the is_domain_name function" do
     result = scope.function_is_domain_name(["not valid"])
     expect(result).to(be_falsey)
   end
+
+  # Values obtained from Facter values will be frozen strings
+  # in newer versions of Facter:
+  it "should not throw an exception if passed a frozen string" do
+    result = scope.function_is_domain_name(["my.domain.name".freeze])
+    expect(result).to(be_truthy)
+  end
 end