Skip to content

validate_integer, validate_numeric: explicitely reject hashes in arrays #461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2015

Conversation

DavidS
Copy link
Contributor

@DavidS DavidS commented May 27, 2015

Without this patch, Ruby 1.8's Hash#to_s behaviour causes [{1=>2}] to be
treated as "12" when validating values.

@@ -109,6 +109,7 @@ module Puppet::Parser::Functions
# check every element of the array
input.each_with_index do |arg, pos|
begin
raise TypeError.new if arg.is_a?(Hash)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .new shouldn't be necessary.

Without this patch, Ruby 1.8's Hash#to_s behaviour causes [{1=>2}] to be
treated as "12" when validating values.
@DavidS DavidS force-pushed the validate-hashes branch from 872a1b7 to cf9f7a6 Compare May 27, 2015 19:05
@DavidS
Copy link
Contributor Author

DavidS commented May 27, 2015

Indeed, thanks for the hint. Also, rebased.

@nibalizer
Copy link
Contributor

This gave me a big belly laugh. Also +1.

tphoney added a commit that referenced this pull request May 28, 2015
validate_integer, validate_numeric: explicitely reject hashes in arrays
@tphoney tphoney merged commit c9b810c into puppetlabs:master May 28, 2015
@DavidS DavidS deleted the validate-hashes branch September 14, 2015 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants