Skip to content

Commit 6835b03

Browse files
authored
šŸ›Storage: quote returned links such that they are usable with files containing parentheses (ITISFoundation#7313)
1 parent b1df292 commit 6835b03

File tree

1 file changed

+29
-16
lines changed
  • services/storage/src/simcore_service_storage/api/rest

1 file changed

+29
-16
lines changed

ā€Žservices/storage/src/simcore_service_storage/api/rest/_files.pyā€Ž

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import logging
33
from typing import Annotated, cast
4+
from urllib.parse import quote
45

56
from fastapi import APIRouter, Depends, Header, HTTPException, Request
67
from models_library.api_schemas_storage.storage_schemas import (
@@ -202,23 +203,31 @@ async def upload_file(
202203
abort_url = (
203204
URL(f"{request.url}")
204205
.with_path(
205-
request.app.url_path_for(
206-
"abort_upload_file",
207-
location_id=f"{location_id}",
208-
file_id=file_id,
209-
)
206+
quote(
207+
request.app.url_path_for(
208+
"abort_upload_file",
209+
location_id=f"{location_id}",
210+
file_id=file_id,
211+
),
212+
safe=":/",
213+
),
214+
encoded=True,
210215
)
211216
.with_query(user_id=query_params.user_id)
212217
)
213218

214219
complete_url = (
215220
URL(f"{request.url}")
216221
.with_path(
217-
request.app.url_path_for(
218-
"complete_upload_file",
219-
location_id=f"{location_id}",
220-
file_id=file_id,
221-
)
222+
quote(
223+
request.app.url_path_for(
224+
"complete_upload_file",
225+
location_id=f"{location_id}",
226+
file_id=file_id,
227+
),
228+
safe=":/",
229+
),
230+
encoded=True,
222231
)
223232
.with_query(user_id=query_params.user_id)
224233
)
@@ -273,12 +282,16 @@ async def complete_upload_file(
273282
route = (
274283
URL(f"{request.url}")
275284
.with_path(
276-
request.app.url_path_for(
277-
"is_completed_upload_file",
278-
location_id=f"{location_id}",
279-
file_id=file_id,
280-
future_id=task.get_name(),
281-
)
285+
quote(
286+
request.app.url_path_for(
287+
"is_completed_upload_file",
288+
location_id=f"{location_id}",
289+
file_id=file_id,
290+
future_id=task.get_name(),
291+
),
292+
safe=":/",
293+
),
294+
encoded=True,
282295
)
283296
.with_query(user_id=query_params.user_id)
284297
)

0 commit comments

Comments
Ā (0)