🐛(backend) normalize raw S3 object keys

Correction to preserve already encoded plus signs in addition to slashes.
This commit is contained in:
ilias
2026-06-29 16:21:57 +02:00
committed by aleb_the_flash
parent 4e5e648730
commit 78acaf395e
2 changed files with 30 additions and 3 deletions
+4 -3
View File
@@ -6,7 +6,7 @@ import re
from dataclasses import dataclass
from functools import lru_cache
from typing import Any, Dict, Optional, Protocol
from urllib.parse import quote_plus
from urllib.parse import quote
from django.conf import settings
from django.utils.module_loading import import_string
@@ -165,8 +165,9 @@ class S3Parser(BaseS3Parser):
if not filepath:
raise ParsingEventDataError("Missing object key name")
filetype, _ = mimetypes.guess_type(filepath)
# Preserve already URL-encoded separators while encoding raw S3 object keys.
filepath = quote_plus(filepath, safe="%")
# Normalize raw S3-compatible object keys without re-encoding
# already encoded AWS S3 notification keys.
filepath = quote(filepath, safe="%+")
return StorageEvent(
filepath=filepath,
filetype=filetype,