Skip to content

Commit a856c39

Browse files
author
Simon Humbert
committed
update handling of length property
1 parent b6ec9cb commit a856c39

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/puppet/type/firewall.rb

+12-10
Original file line numberDiff line numberDiff line change
@@ -1393,22 +1393,24 @@ def insync?(is)
13931393
EOS
13941394

13951395
munge do |value|
1396-
match = value.to_s.match("([0-9]+)(-)?([0-9]+)?")
1397-
low = match[1].to_int
1398-
high = match[3].to_int
1399-
1400-
if low.nil? or (low and match[2] and high.nil?)
1396+
match = value.to_s.match("^([0-9]+)(-)?([0-9]+)?$")
1397+
if match.nil?
14011398
raise ArgumentError, "Length value must either be an integer or a range"
14021399
end
14031400

1404-
if (low < 0 or low > 65535)
1405-
or (high and (high < 0 or high > 65535 or high < low))
1401+
low = match[1].to_i
1402+
if !match[3].nil?
1403+
high = match[3].to_i
1404+
end
1405+
1406+
if (low < 0 or low > 65535) or \
1407+
(!high.nil? and (high < 0 or high > 65535 or high < low))
14061408
raise ArgumentError, "Length values must be between 0 and 65535"
14071409
end
14081410

1409-
value = low
1410-
if high
1411-
value = value + ":#{high}"
1411+
value = low.to_s
1412+
if !high.nil?
1413+
value << ":" << high.to_s
14121414
end
14131415
value
14141416
end

0 commit comments

Comments
 (0)