From b3bc1e75aa5a5556fef014469a5263059c0c169c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 4 Sep 2020 10:31:02 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Ensure=20download=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/util/net.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/octoprint/util/net.py b/src/octoprint/util/net.py index 0fa252b95..d12a32589 100644 --- a/src/octoprint/util/net.py +++ b/src/octoprint/util/net.py @@ -214,7 +214,9 @@ def download_file(url, folder, max_length=None): # TODO check content-length against safety limit - path = os.path.join(folder, filename) + path = os.path.abspath(os.path.join(folder, filename)) + assert path.startswith(folder) + with io.open(path, 'wb') as f: for chunk in r.iter_content(chunk_size=8192): f.write(chunk)