[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. puppet-0.24.5-rc3-1456-g2f0b1e5

James Turnbull james at lovedthanlost.net
Tue Oct 27 17:05:00 UTC 2009


The following commit has been merged in the upstream branch:
commit d21b2664abcb13df2967af8caa881e41b19b3b81
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Sun Sep 13 23:00:41 2009 +0200

    Fix #2627 - regex node name could lead to invalid tag
    
    We're converting the regex to a straight name to be used as the node
    class name which later on will be used as tag.
    It was possible to generate an invalid tag name (containing leading
    or successive dots).
    
    Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>

diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb
index d10ea62..2f00ea7 100644
--- a/lib/puppet/parser/ast/leaf.rb
+++ b/lib/puppet/parser/ast/leaf.rb
@@ -102,9 +102,7 @@ class Puppet::Parser::AST
         end
 
         def to_classname
-            classname = @value.to_s.downcase
-            classname.gsub!(/[^-a-zA-Z0-9:.]/,'') if regex?
-            classname
+            to_s.downcase.gsub(/[^-a-zA-Z0-9:.]/,'').sub(/^\.+/,'')
         end
 
         # implementing eql? and hash so that when an HostName is stored
diff --git a/spec/unit/parser/ast/leaf.rb b/spec/unit/parser/ast/leaf.rb
index 6215f63..69b704a 100755
--- a/spec/unit/parser/ast/leaf.rb
+++ b/spec/unit/parser/ast/leaf.rb
@@ -200,6 +200,11 @@ describe Puppet::Parser::AST::HostName do
         host.to_classname.should == "this-isnotaclassname"
     end
 
+    it "should return a string usable as a tag when calling to_classname" do
+        host = Puppet::Parser::AST::HostName.new( :value => Puppet::Parser::AST::Regex.new(:value => "/.+.reductivelabs\.com/") )
+        host.to_classname.should == "reductivelabs.com"
+    end
+
     it "should delegate 'match' to the underlying value if it is an HostName" do
         @value.expects(:match).with("value")
         @host.match("value")

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list