The #2627 fix was modifying nodename in case of string nodename.
This patch restores the original behaviour which was to not touch the
string nodename, and only make sure regex node names are properly sanitized
to be used as classnames or tags.

Signed-off-by: Brice Figureau <[email protected]>
---
 lib/puppet/parser/ast/leaf.rb |    3 ++-
 spec/unit/parser/ast/leaf.rb  |   10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb
index 2f00ea7..3e99444 100644
--- a/lib/puppet/parser/ast/leaf.rb
+++ b/lib/puppet/parser/ast/leaf.rb
@@ -102,7 +102,8 @@ class Puppet::Parser::AST
         end
 
         def to_classname
-            to_s.downcase.gsub(/[^-a-zA-Z0-9:.]/,'').sub(/^\.+/,'')
+            return to_s.downcase.gsub(/[^-a-zA-Z0-9:._]/,'').sub(/^\.+/,'') if 
regex?
+            return @value
         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 69b704a..95d5045 100755
--- a/spec/unit/parser/ast/leaf.rb
+++ b/spec/unit/parser/ast/leaf.rb
@@ -195,6 +195,16 @@ describe Puppet::Parser::AST::HostName do
         host.to_classname.should == "klassname"
     end
 
+    it "should not tamper string nodename" do
+        value = stub 'value'
+        value.stubs(:to_s).returns(value)
+        value.stubs(:downcase).returns(value)
+        value.stubs(:=~).returns(false)
+
+        host = Puppet::Parser::AST::HostName.new( :value => value )
+        host.to_classname.should === value
+    end
+
     it "should return a string usable as classname when calling to_classname" 
do
         host = Puppet::Parser::AST::HostName.new( :value => 
Puppet::Parser::AST::Regex.new(:value => "/^this-is n...@a classname$/") )
         host.to_classname.should == "this-isnotaclassname"
-- 
1.6.4


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to