From 8194be795de5d28714f078bb3b16379dac53f972 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 18 Nov 2025 16:06:57 +0100 Subject: [PATCH 1/2] fix: encode s3 metadata as base64 if needed Signed-off-by: Robin Appelman --- lib/private/Files/ObjectStore/S3.php | 3 +++ lib/private/Files/ObjectStore/S3ObjectTrait.php | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/private/Files/ObjectStore/S3.php b/lib/private/Files/ObjectStore/S3.php index 72e1751e23d3c..e92346e4ccc01 100644 --- a/lib/private/Files/ObjectStore/S3.php +++ b/lib/private/Files/ObjectStore/S3.php @@ -100,6 +100,9 @@ private function parseS3Metadata(array $metadata): array { $result = []; foreach ($metadata as $key => $value) { if (str_starts_with($key, 'x-amz-meta-')) { + if (str_starts_with($value, 'base64:')) { + $value = base64_decode(substr($value, 7)); + } $result[substr($key, strlen('x-amz-meta-'))] = $value; } } diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php index 9362609fa5ad2..f47a01dab18b3 100644 --- a/lib/private/Files/ObjectStore/S3ObjectTrait.php +++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php @@ -82,7 +82,11 @@ public function readObject($urn) { private function buildS3Metadata(array $metadata): array { $result = []; foreach ($metadata as $key => $value) { - $result['x-amz-meta-' . $key] = $value; + if (mb_check_encoding($value, 'ASCII')) { + $result['x-amz-meta-' . $key] = $value; + } else { + $result['x-amz-meta-' . $key] = 'base64:' . base64_encode($value); + } } return $result; } From a7d130c598e4f5e1034763d1c079eecbdde5cbc4 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 18 Nov 2025 16:07:29 +0100 Subject: [PATCH 2/2] Revert "fix(ObjectStoreStorage): Encode original-path in writeStream by @frabe1579" This reverts commit 4b4b39e7ec6d8cc33effc8a0923eafde10aefa41. Signed-off-by: Robin Appelman --- lib/private/Files/ObjectStore/ObjectStoreStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 323da62ce46b0..8ce992e93c050 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -480,7 +480,7 @@ public function writeStream(string $path, $stream, ?int $size = null): int { $metadata = [ 'mimetype' => $mimetype, 'original-storage' => $this->getId(), - 'original-path' => rawurlencode($path), + 'original-path' => $path, ]; if ($size) { $metadata['size'] = $size;