Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion faraday-curl.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|

spec.add_dependency "faraday", ">= 0.9.0"

spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "rake"
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'faraday_middleware', ">= 0.9.0"
Expand Down
4 changes: 2 additions & 2 deletions lib/faraday/curl/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def call(env)
end

def quote(value)
value.gsub("'", "\\'")
value.gsub("'") { "'\\''" }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value is not always a String. In some case it can be a Boolean

end
end
end
end

Faraday::Request.register_middleware :curl => Faraday::Curl::Middleware
Faraday::Request.register_middleware :curl => Faraday::Curl::Middleware
12 changes: 10 additions & 2 deletions spec/curl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

describe Faraday::Curl::Middleware do

let(:version) { "-H 'User-Agent: Faraday v0.9.0'" }
let(:version) { "-H 'User-Agent: Faraday v#{Faraday::VERSION}'" }

def create_connection( *request_middlewares )
Faraday.new( :url => 'http://example.com' ) do |b|
Expand Down Expand Up @@ -49,4 +49,12 @@ def match_command( response, method, *parts )
match_command(response, "PUT", "-H 'Content-Type: application/x-www-form-urlencoded'", "-d 'age=50&name%5B%5D=john&name%5B%5D=doe'", '"http://example.com/echo"')
end

end
it 'should escape headers' do
connection = create_connection
response = connection.get( "/echo" ) do |request|
request.headers["Cookies"] = "exa'mple"
end
match_command(response, "GET", "-H 'Cookies: exa'\\''mple'", '"http://example.com/echo"')
end

end