summaryrefslogtreecommitdiff
path: root/kvmd/apps
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2023-03-17 00:10:51 +0200
committerMaxim Devaev <[email protected]>2023-03-17 00:10:51 +0200
commit921d7da513c663eaaa690472beccb0d8d0c5a310 (patch)
treed7553276780da9f1c65622b38387cce7b186ea2b /kvmd/apps
parent74a19e40dae259d530ef5420663ccfaf7ba38f51 (diff)
optional upload prefix
Diffstat (limited to 'kvmd/apps')
-rw-r--r--kvmd/apps/kvmd/api/msd.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/kvmd/apps/kvmd/api/msd.py b/kvmd/apps/kvmd/api/msd.py
index 16118141..59915864 100644
--- a/kvmd/apps/kvmd/api/msd.py
+++ b/kvmd/apps/kvmd/api/msd.py
@@ -136,7 +136,8 @@ class MsdApi:
@exposed_http("POST", "/msd/write")
async def __write_handler(self, request: Request) -> Response:
- name = valid_msd_image_name(request.query.get("image"))
+ unsafe_prefix = request.query.get("prefix", "") + "/"
+ name = valid_msd_image_name(unsafe_prefix + request.query.get("image", ""))
size = valid_int_f0(request.content_length)
remove_incomplete = self.__get_remove_incomplete(request)
written = 0
@@ -151,6 +152,7 @@ class MsdApi:
@exposed_http("POST", "/msd/write_remote")
async def __write_remote_handler(self, request: Request) -> (Response | StreamResponse): # pylint: disable=too-many-locals
+ unsafe_prefix = request.query.get("prefix", "") + "/"
url = valid_url(request.query.get("url"))
insecure = valid_bool(request.query.get("insecure", False))
timeout = valid_float_f01(request.query.get("timeout", 10.0))
@@ -175,7 +177,7 @@ class MsdApi:
name = str(request.query.get("image", "")).strip()
if len(name) == 0:
name = htclient.get_filename(remote)
- name = valid_msd_image_name(name)
+ name = valid_msd_image_name(unsafe_prefix + name)
size = valid_int_f0(remote.content_length)