[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.4-89-gcbbd363

James Turnbull james at lovedthanlost.net
Tue May 18 09:03:52 UTC 2010


The following commit has been merged in the upstream branch:
commit 7ec50a74f81264591208fb55e01567ee795ab6b8
Author: Bryan Kearney <bkearney at redhat.com>
Date:   Mon Mar 22 08:36:07 2010 -0400

    Fixes #3387 - Handle path elements with ticks and spaces
    
    Unit tests for path changes

diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
index 5b9133a..6e471b8 100644
--- a/lib/puppet/provider/augeas/augeas.rb
+++ b/lib/puppet/provider/augeas/augeas.rb
@@ -82,18 +82,24 @@ Puppet::Type.type(:augeas).provide(:augeas) do
                 if f == :path
                     start = sc.pos
                     nbracket = 0
+                    inSingleTick = false
+                    inDoubleTick = false
                     begin
-                        sc.skip(/([^\]\[\s\\]|\\.)+/)
+                        sc.skip(/([^\]\[\s\\'"]|\\.)+/)
                         ch = sc.getch
                         nbracket += 1 if ch == "["
                         nbracket -= 1 if ch == "]"
+                        inSingleTick = !inSingleTick if ch == "'"
+                        inDoubleTick = !inDoubleTick if ch == "\""
                         fail("unmatched [") if nbracket < 0
-                    end until nbracket == 0 && (sc.eos? || ch =~ /\s/)
+                    end until ((nbracket == 0 && !inSingleTick && !inDoubleTick && (ch =~ /\s/)) || sc.eos?)
                         len = sc.pos - start
                         len -= 1 unless sc.eos?
                     unless p = sc.string[start, len]
                         fail("missing path argument #{narg} for #{cmd}")
                     end
+                    # Rip off any ticks if they are there.
+                    p = p[1, (p.size - 2)] if p[0,1] == "'" || p[0,1] == "\""
                     p.chomp!("/")
                     if p[0,1] != "$" && p[0,1] != "/"
                         argline << context + p
@@ -278,7 +284,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do
                     save_result = @aug.save
                     saved_files = @aug.match("/augeas/events/saved")
                     if save_result and not files_changed?
-                        debug("Skipping becuase no files were changed")
+                        debug("Skipping because no files were changed")
                         return_value = false
                     else
                         debug("Files changed, should execute")
diff --git a/lib/puppet/type/augeas.rb b/lib/puppet/type/augeas.rb
index cfd1da5..49d6d5f 100644
--- a/lib/puppet/type/augeas.rb
+++ b/lib/puppet/type/augeas.rb
@@ -145,7 +145,7 @@ Puppet::Type.newtype(:augeas) do
         end
 
         # if the onlyif resource is provided, then the value is parsed.
-        # a return value of 0 will stop exection becuase it matches the
+        # a return value of 0 will stop exection because it matches the
         # default value.
         def retrieve
             if @resource.provider.need_to_run?()
diff --git a/spec/unit/provider/augeas/augeas.rb b/spec/unit/provider/augeas/augeas.rb
index 067126c..22f7bed 100644
--- a/spec/unit/provider/augeas/augeas.rb
+++ b/spec/unit/provider/augeas/augeas.rb
@@ -141,6 +141,20 @@ describe provider_class do
             tokens.should == [ args ]
         end
 
+        it "should allow single quoted escaped spaces in paths" do
+            @resource.stubs(:[]).returns("/foo/")
+            args = [ "set", "'/white\\ space/key'", "value" ]
+            tokens = @provider.parse_commands(args.join(" \t "))
+            tokens.should == [[ "set", "/white\\ space/key", "value" ]]
+        end
+
+        it "should allow double quoted escaped spaces in paths" do
+            @resource.stubs(:[]).returns("/foo/")
+            args = [ "set", '"/white\\ space/key"', "value" ]
+            tokens = @provider.parse_commands(args.join(" \t "))
+            tokens.should == [[ "set", "/white\\ space/key", "value" ]]
+        end
+
         it "should remove trailing slashes" do
             @resource.stubs(:[]).returns("/foo/")
             tokens = @provider.parse_commands("set foo/ bar")

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list