(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!
This commit is contained in:
Sean Millichamp 2015-02-14 10:46:34 -05:00
parent ad5727266a
commit 1321d586a8
2 changed files with 8 additions and 1 deletions

View 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

View file

@ -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