Commits

Kaspar Schiess committed 3ccbc43

+ Proper quoting on snapshot names

Comments (0)

Files changed (2)

lib/zfs/dataset.rb

     snapshot_name = sanitize_snapshot_name(name)
     
     arguments << '-r' if recursive
-    arguments << self.name + "@" + snapshot_name
+    arguments << "'#{self.name}@#{snapshot_name}'"
     
     zfs_snapshot(*arguments)
     

spec/unit/zfs/dataset_spec.rb

   describe "<- #snapshot" do
     it "should snapshot with the given name" do
       flexmock(dataset).
-        should_receive(:zfs_snapshot).with('pool1/backup/active@given_name').once
+        should_receive(:zfs_snapshot).with("'pool1/backup/active@given_name'").once
         
       dataset.snapshot('given_name')
     end 
     it "should transform illegal characters" do
       flexmock(dataset).
-        should_receive(:zfs_snapshot).with('pool1/backup/active@010203-word_______-_').once
+        should_receive(:zfs_snapshot).with("'pool1/backup/active@010203-word_______-_'").once
         
       dataset.snapshot('010203-word !!! _ - ')
     end 
     it "should allow recursive snapshots" do
       flexmock(dataset).
-        should_receive(:zfs_snapshot).with('-r', 'pool1/backup/active@name').once
+        should_receive(:zfs_snapshot).with('-r', "'pool1/backup/active@name'").once
         
       dataset.snapshot('name', true)
     end