Skip to content

Commit 2e47d42

Browse files
committed
Merge pull request #60 from mrbrdo/master
Fix curl escape
2 parents fd3e8d8 + 9a90a64 commit 2e47d42

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/rspec_api_documentation/curl.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def get_data
4040
end
4141

4242
def post_data
43-
"-d \"#{data}\""
43+
escaped_data = data.to_s.gsub("'", "\\u0027")
44+
"-d '#{escaped_data}'"
4445
end
4546

4647
private

spec/curl_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
it { should =~ /^curl/ }
1515
it { should =~ /http:\/\/example\.com\/orders/ }
16-
it { should =~ /-d "order%5Bsize%5D=large&order%5Btype%5D=cart"/ }
16+
it { should =~ /-d 'order%5Bsize%5D=large&order%5Btype%5D=cart'/ }
1717
it { should =~ /-X POST/ }
1818
it { should =~ /-H "Accept: application\/json"/ }
1919
it { should =~ /-H "X-Header: header"/ }
@@ -50,7 +50,7 @@
5050

5151
it { should =~ /^curl/ }
5252
it { should =~ /http:\/\/example\.com\/orders\/1/ }
53-
it { should =~ /-d "size=large"/ }
53+
it { should =~ /-d 'size=large'/ }
5454
it { should =~ /-X PUT/ }
5555
it { should =~ /-H "Accept: application\/json"/ }
5656
it { should =~ /-H "X-Header: header"/ }

0 commit comments

Comments
 (0)