dumpdb 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -62,6 +62,7 @@ module Dumpdb::Settings
62
62
  def value(script, placeholder_vals={})
63
63
  val = super(script, script.source.to_hash.merge(placeholder_vals))
64
64
  if script.ssh?
65
+ val = val.gsub("\\", "\\\\\\").gsub('"', '\"')
65
66
  val = "ssh -A #{script.ssh_opts} #{script.ssh} \"#{val}\""
66
67
  end
67
68
  val
@@ -1,3 +1,3 @@
1
1
  module Dumpdb
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -126,6 +126,20 @@ module Dumpdb
126
126
  assert_equal "this is the local db: devdb", cmd_val
127
127
  end
128
128
 
129
+ should "not escape any double-quotes in the cmds" do
130
+ orig_cmd = "do_something --value=\"a_val\""
131
+ cmd_val = Settings::DumpCmd.new(Proc.new { orig_cmd }).value(@script)
132
+
133
+ assert_equal orig_cmd, cmd_val
134
+ end
135
+
136
+ should "not escape any backslashes in the cmds" do
137
+ orig_cmd = "do \\something"
138
+ cmd_val = Settings::DumpCmd.new(Proc.new { orig_cmd }).value(@script)
139
+
140
+ assert_equal orig_cmd, cmd_val
141
+ end
142
+
129
143
  end
130
144
 
131
145
  class RemoteDumpCmdTests < DumpCmdTests
@@ -142,6 +156,33 @@ module Dumpdb
142
156
  assert_equal exp_cmd_str, cmd_val
143
157
  end
144
158
 
159
+ should "escape any double-quotes in the cmds" do
160
+ orig_cmd = "do_something --value=\"a_val\""
161
+ exp_esc_cmd = "do_something --value=\\\"a_val\\\""
162
+ exp_cmd_str = "ssh -A #{@script.ssh_opts} #{@script.ssh} \"#{exp_esc_cmd}\""
163
+ cmd_val = Settings::DumpCmd.new(Proc.new { orig_cmd }).value(@script)
164
+
165
+ assert_equal exp_cmd_str, cmd_val
166
+ end
167
+
168
+ should "escape any backslashes in the cmds" do
169
+ orig_cmd = "do \\something"
170
+ exp_esc_cmd = "do \\\\something"
171
+ exp_cmd_str = "ssh -A #{@script.ssh_opts} #{@script.ssh} \"#{exp_esc_cmd}\""
172
+ cmd_val = Settings::DumpCmd.new(Proc.new { orig_cmd }).value(@script)
173
+
174
+ assert_equal exp_cmd_str, cmd_val
175
+ end
176
+
177
+ should "escape any backslashes before double-quotes in the cmds" do
178
+ orig_cmd = "do \\something --value=\"a_val\""
179
+ exp_esc_cmd = "do \\\\something --value=\\\"a_val\\\""
180
+ exp_cmd_str = "ssh -A #{@script.ssh_opts} #{@script.ssh} \"#{exp_esc_cmd}\""
181
+ cmd_val = Settings::DumpCmd.new(Proc.new { orig_cmd }).value(@script)
182
+
183
+ assert_equal exp_cmd_str, cmd_val
184
+ end
185
+
145
186
  end
146
187
 
147
188
  class RestoreCmdTests < CmdTests
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dumpdb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-12-18 00:00:00 Z
19
+ date: 2012-12-20 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: assert