From 1321d586a88edb7c8bf07c5edb2d5ce2ae44c1a3 Mon Sep 17 00:00:00 2001 From: Sean Millichamp Date: Sat, 14 Feb 2015 10:46:34 -0500 Subject: [PATCH] (MODULES-1771) Don't modify input to is_domain_name() 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 | 2 +- spec/functions/is_domain_name_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/puppet/parser/functions/is_domain_name.rb b/lib/puppet/parser/functions/is_domain_name.rb index b3fee965a..24cc2085f 100644 --- a/lib/puppet/parser/functions/is_domain_name.rb +++ b/lib/puppet/parser/functions/is_domain_name.rb @@ -13,7 +13,7 @@ module Puppet::Parser::Functions "given #{arguments.size} for 1") end - domain = arguments[0] + domain = arguments[0].dup # Limits (rfc1035, 3.1) domain_max_length=255 diff --git a/spec/functions/is_domain_name_spec.rb b/spec/functions/is_domain_name_spec.rb index 4d05f5cdc..5ab8369c0 100755 --- a/spec/functions/is_domain_name_spec.rb +++ b/spec/functions/is_domain_name_spec.rb @@ -61,4 +61,11 @@ 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