From a856c394cfc65e079fdcd8af23540c249eb1bf6d Mon Sep 17 00:00:00 2001 From: Simon Humbert Date: Tue, 3 May 2016 17:11:29 -0400 Subject: [PATCH] update handling of length property --- lib/puppet/type/firewall.rb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/puppet/type/firewall.rb b/lib/puppet/type/firewall.rb index 35fac12..fd0ec54 100644 --- a/lib/puppet/type/firewall.rb +++ b/lib/puppet/type/firewall.rb @@ -1393,22 +1393,24 @@ Puppet::Type.newtype(:firewall) do EOS munge do |value| - match = value.to_s.match("([0-9]+)(-)?([0-9]+)?") - low = match[1].to_int - high = match[3].to_int - - if low.nil? or (low and match[2] and high.nil?) + match = value.to_s.match("^([0-9]+)(-)?([0-9]+)?$") + if match.nil? raise ArgumentError, "Length value must either be an integer or a range" end - if (low < 0 or low > 65535) - or (high and (high < 0 or high > 65535 or high < low)) + low = match[1].to_i + if !match[3].nil? + high = match[3].to_i + end + + if (low < 0 or low > 65535) or \ + (!high.nil? and (high < 0 or high > 65535 or high < low)) raise ArgumentError, "Length values must be between 0 and 65535" end - value = low - if high - value = value + ":#{high}" + value = low.to_s + if !high.nil? + value << ":" << high.to_s end value end -- 2.45.2