Skip to content

Commit

Permalink
quote parameters to shell command
Browse files Browse the repository at this point in the history
  • Loading branch information
lewang committed Aug 13, 2015
1 parent 1d3b281 commit 84f8eef
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions helper/download-helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'shellwords'

module ViddlRb

class RequirementError < StandardError; end
Expand All @@ -23,14 +25,20 @@ def get_command(download_url, save_path)
TOOLS_PRIORITY_LIST = [

Tool.new(:aria2c) do |url, path|
url = Shellwords.escape(url)
path = Shellwords.escape(url)
"aria2c #{url.inspect} -U 'Wget/1.8.1' -x4 -d #{File.dirname(path).inspect} -o #{File.basename(path).inspect}"
end,

Tool.new(:wget) do |url, path|
url = Shellwords.escape(url)
path = Shellwords.escape(url)
"wget -c #{url.inspect} -O #{path.inspect}"
end,

Tool.new(:curl) do |url, path|
url = Shellwords.escape(url)
path = Shellwords.escape(url)
"curl -A 'Wget/1.8.1' --retry 10 --retry-delay 5 --retry-max-time 4 -L #{url.inspect} -o #{path.inspect}"
end
]
Expand Down

0 comments on commit 84f8eef

Please sign in to comment.