From 437a3928f243d7a1c8d55ea60f46b5558bd7b190 Mon Sep 17 00:00:00 2001 From: Le Wang Date: Wed, 12 Aug 2015 23:13:21 -0400 Subject: [PATCH] quote parameters to shell command --- helper/download-helper.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/helper/download-helper.rb b/helper/download-helper.rb index 4e1dcb8..f140a57 100755 --- a/helper/download-helper.rb +++ b/helper/download-helper.rb @@ -1,3 +1,5 @@ +require 'shellwords' + module ViddlRb class RequirementError < StandardError; end @@ -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(path) "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(path) "wget -c #{url.inspect} -O #{path.inspect}" end, Tool.new(:curl) do |url, path| + url = Shellwords.escape(url) + path = Shellwords.escape(path) "curl -A 'Wget/1.8.1' --retry 10 --retry-delay 5 --retry-max-time 4 -L #{url.inspect} -o #{path.inspect}" end ]