Skip to content

Conversation

cvrebert
Copy link

In general, shelling out is relatively error-prone given that one must remember to escape/quote shell metacharacters all the time, including spaces in filenames. For these curl and tar commands, there's no need to be using the shell in the first place, since no shell features are being used. So this switches them to use Open3.popen3 with an array argument instead (which shouldn't invoke the shell).
Also, the old code used %p for some shell escaping, even though String#inspect is not intended to be used for that purpose.

Since travis-ci/travis-ci#5092 involves Cacher, I'm looking for possible bugs in Cacher.

@cvrebert
Copy link
Author

@BanzaiMan Ping

@fetch_tar = File.expand_path('fetch.tgz', @casher_dir) if path_ext(url) == 'tgz'

if system "curl --tcp-nodelay -w '#{CURL_FORMAT}' %p -o %p -f -s --retry 3 >#{@casher_dir}/fetch.log 2>#{@casher_dir}/fetch.err.log" % [url, @fetch_tar]
args = ['curl', '--tcp-nodelay', '-w', CURL_FORMAT, '-o', @fetch_tar, '-f', '-s', '--retry', '3', url]

This comment was marked as spam.

@BanzaiMan
Copy link
Contributor

Sorry for the delay. I like the idea, but there may be some issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants