Skip to content

Commit cd231dd

Browse files
committed
feat(ocm): minor fixes
Signed-off-by: Maxence Lange <[email protected]>
1 parent 8210abd commit cd231dd

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

apps/cloud_federation_api/lib/Controller/OCMRequestController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ public function __construct(
5353
#[PublicPage]
5454
#[BruteForceProtection(action: 'receiveOcmRequest')]
5555
public function manageOCMRequests(string $ocmPath): Response {
56-
try {
57-
json_encode($ocmPath, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES);
58-
} catch (JsonException) {
56+
if (!mb_check_encoding($ocmPath, 'UTF-8')) {
5957
throw new OCMArgumentException('path is not UTF-8');
6058
}
6159

@@ -71,15 +69,15 @@ public function manageOCMRequests(string $ocmPath): Response {
7169
// assuming that ocm request contains a json array
7270
$payload = $signedRequest?->getBody() ?? file_get_contents('php://input');
7371
try {
74-
$payload = (!$payload) ? null : json_decode($payload, true, 512, JSON_THROW_ON_ERROR);
72+
$payload = ($payload) ? json_decode($payload, true, 512, JSON_THROW_ON_ERROR) : null;
7573
} catch (JsonException $e) {
7674
$this->logger->debug('json decode error', ['exception' => $e]);
7775
$payload = null;
7876
}
7977

8078
$event = new OCMEndpointRequestEvent(
8179
$this->request->getMethod(),
82-
str_replace('//', '/', $ocmPath),
80+
preg_replace('@/+@', '/', $ocmPath),
8381
$payload,
8482
$signedRequest?->getOrigin()
8583
);

0 commit comments

Comments
 (0)