[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.7-1-98-gf19c0e5

James Turnbull james at lovedthanlost.net
Wed Apr 8 21:48:23 UTC 2009


The following commit has been merged in the master branch:
commit 73a0757b559d7e4fbd1da43bbcf4e60fd9155896
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Fri Dec 19 15:05:29 2008 +0100

    Fix #1828 - Scope.number? wasn't strict enough and could produce wrong results
    
    Some invalid numbers were treated as numbers and conversion to Integer
    was failing returning 0 (for instance 0.24.7).
    
    Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>

diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index 4acdf41..77e7b0c 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -52,11 +52,11 @@ class Puppet::Parser::Scope
         if value.is_a?(String)
             if value =~ /^-?\d+(:?\.\d+|(:?\.\d+)?e\d+)$/
                 return value.to_f
-            elsif value =~ /^0x\d+/i
+            elsif value =~ /^0x[0-9a-f]+$/i
                 return value.to_i(16)
-            elsif value =~ /^0\d+/i
+            elsif value =~ /^0[0-7]+$/
                 return value.to_i(8)
-            elsif value =~ /^-?\d+/
+            elsif value =~ /^-?\d+$/
                 return value.to_i
             else
                 return nil
diff --git a/spec/unit/parser/scope.rb b/spec/unit/parser/scope.rb
index fa76c4f..1355952 100755
--- a/spec/unit/parser/scope.rb
+++ b/spec/unit/parser/scope.rb
@@ -81,7 +81,21 @@ describe Puppet::Parser::Scope do
             Puppet::Parser::Scope.number?("0755").should == 0755
         end
 
+        it "should return nil on malformed integers" do
+            Puppet::Parser::Scope.number?("0.24.5").should be_nil
+        end
+
+        it "should convert strings with leading 0 to integer if they are not octal" do
+            Puppet::Parser::Scope.number?("0788").should == 788
+        end
 
+        it "should convert strings of negative integers" do
+            Puppet::Parser::Scope.number?("-0788").should == -788
+        end
+
+        it "should return nil on malformed hexadecimal numbers" do
+            Puppet::Parser::Scope.number?("0x89g").should be_nil
+        end
     end
 
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list