Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.
Open
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
6 changes: 5 additions & 1 deletion lib/shrimp/phantom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def cmd
def initialize(url_or_file, options = { }, cookies={ }, outfile = nil)
@source = Source.new(url_or_file)
@options = Shrimp.configuration.default_options.merge(options)
@cookies = cookies
@cookies = escape_cookies(cookies)
@outfile = File.expand_path(outfile) if outfile
raise NoExecutableError.new unless File.exists?(Shrimp.configuration.phantomjs)
end
Expand Down Expand Up @@ -149,5 +149,9 @@ def dump_cookies
json = @cookies.inject([]) { |a, (k, v)| a.push({ :name => k, :value => v, :domain => host }); a }.to_json
File.open("#{options[:tmpdir]}/#{rand}.cookies", 'w') { |f| f.puts json; f }.path
end

def escape_cookies(cookies)
Hash[cookies.map { |key, value| [key, CGI.escape(value)] }]
end
end
end