From a53109335f520941642a43d528decd03aa28f45c Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 10 Sep 2026 14:41:55 -0700 Subject: [PATCH] refactor(proxy): type the decode step the raw cloud storage file id guard folds over --- litellm/litellm_core_utils/cloud_storage_security.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/cloud_storage_security.py b/litellm/litellm_core_utils/cloud_storage_security.py index 87c586459a5..b936c904979 100644 --- a/litellm/litellm_core_utils/cloud_storage_security.py +++ b/litellm/litellm_core_utils/cloud_storage_security.py @@ -24,8 +24,12 @@ _MAPPING_PROXY_TYPE: Final[type] = type(MappingProxyType({})) MAX_FILE_ID_DECODE_PASSES: Final = 8 +def _unquote_once(current: str, _: str) -> str: + return unquote(current) + + def _decodings(value: str) -> tuple[str, ...]: - return tuple(accumulate(repeat(value, MAX_FILE_ID_DECODE_PASSES + 2), lambda current, _: unquote(current))) + return tuple(accumulate(repeat(value, MAX_FILE_ID_DECODE_PASSES + 2), _unquote_once)) def is_managed_cloud_storage_uri(file_id: str) -> bool: