Skip to content

Commit 1b02bc1

Browse files
committed
Use cwd for Popen, and quote source url
1 parent 492fae9 commit 1b02bc1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

bin/stashcp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,13 @@ def download_with_http(source, destination, debug):
339339

340340
# Append port 8000, which is just a convention for now, not set in stone
341341
cache += ":8000"
342-
curl_command = "cd %s; curl %s -L --connect-timeout 30 --speed-limit 1024 %s --fail %s%s" % (dest_dir, output_mode, download_output, cache, source)
342+
343+
# Quote the source URL, which may have weird, dangerous characters
344+
quoted_source = urllib2.quote(source)
345+
curl_command = "curl %s -L --connect-timeout 30 --speed-limit 1024 %s --fail %s%s" % (output_mode, download_output, cache, quoted_source)
343346
logging.debug("About to run curl command: %s", curl_command)
344347
start = int(time.time()*1000)
345-
command_object = subprocess.Popen([curl_command], shell=True)
348+
command_object = subprocess.Popen([curl_command], shell=True, cwd=dest_dir)
346349
command_object.wait()
347350
end = int(time.time()*1000)
348351

0 commit comments

Comments
 (0)