File tree Expand file tree Collapse file tree 7 files changed +20
-6
lines changed
lib/puppet/parser/functions Expand file tree Collapse file tree 7 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,12 @@ module Puppet::Parser::Functions
88 raise ( Puppet ::ParseError , "floor(): Wrong number of arguments " +
99 "given (#{ arguments . size } for 1)" ) if arguments . size != 1
1010
11- arg = arguments [ 0 ]
11+ begin
12+ arg = Float ( arguments [ 0 ] )
13+ rescue TypeError , ArgumentError => e
14+ raise ( Puppet ::ParseError , "floor(): Wrong argument type " +
15+ "given (#{ arguments [ 0 ] } for Numeric)" )
16+ end
1217
1318 raise ( Puppet ::ParseError , "floor(): Wrong argument type " +
1419 "given (#{ arg . class } for Numeric)" ) if arg . is_a? ( Numeric ) == false
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ module Puppet::Parser::Functions
2020 label_min_length = 1
2121 label_max_length = 63
2222
23+ # Only allow string types
24+ return false unless domain . is_a? ( String )
25+
2326 # Allow ".", it is the top level domain
2427 return true if domain == '.'
2528
Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ module Puppet::Parser::Functions
1515
1616 value = arguments [ 0 ]
1717
18+ # Only allow Numeric or String types
19+ return false unless value . is_a? ( Numeric ) or value . is_a? ( String )
20+
1821 if value != value . to_f . to_s and !value . is_a? Float then
1922 return false
2023 else
Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ module Puppet::Parser::Functions
1515 "given #{ arguments . size } for 1" )
1616 end
1717
18+ # Only allow String types
19+ return false unless arguments [ 0 ] . is_a? ( String )
20+
1821 function = Puppet ::Parser ::Functions . function ( arguments [ 0 ] . to_sym )
1922 function . is_a? ( String ) and not function . empty?
2023 end
Original file line number Diff line number Diff line change 1313 notice(inline_template('getparam is <%= @o.inspect %>'))
1414 EOS
1515
16- apply_manifest ( pp , :expect_changes => true ) do |r |
16+ apply_manifest ( pp , :catch_failures => true ) do |r |
1717 expect ( r . stdout ) . to match ( /getparam is true/ )
1818 end
1919 end
Original file line number Diff line number Diff line change 77 pp = <<-EOS
88 $a = ['aaa.com','bbb','ccc']
99 $o = is_float($a)
10- notice(inline_template('is_floats is <%= @o.inspect %>'))
10+ notice(inline_template('is_float is <%= @o.inspect %>'))
1111 EOS
1212
1313 apply_manifest ( pp , :catch_failures => true ) do |r |
1818 pp = <<-EOS
1919 $a = true
2020 $o = is_float($a)
21- notice(inline_template('is_floats is <%= @o.inspect %>'))
21+ notice(inline_template('is_float is <%= @o.inspect %>'))
2222 EOS
2323
2424 apply_manifest ( pp , :catch_failures => true ) do |r |
7575 EOS
7676
7777 apply_manifest ( pp , :catch_failures => true ) do |r |
78- expect ( r . stdout ) . to match ( /is_floats is false/ )
78+ expect ( r . stdout ) . to match ( /is_float is false/ )
7979 end
8080 end
8181 end
Original file line number Diff line number Diff line change 5050 EOS
5151
5252 apply_manifest ( pp , :catch_failures => true ) do |r |
53- expect ( r . stdout ) . to match ( /is_string is true / )
53+ expect ( r . stdout ) . to match ( /is_string is false / )
5454 end
5555 end
5656 it 'is_strings floats' do
You can’t perform that action at this time.
0 commit comments