From dacee04be8839c66a77135e5436cbf5862bfff6e Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Mon, 4 Dec 2023 23:05:46 +0300 Subject: [PATCH] cutoff starting slash in ExApp url before writing to DB --- lib/Service/UI/FilesActionsMenuService.php | 2 +- lib/Service/UI/ScriptsService.php | 4 ++-- lib/Service/UI/StylesService.php | 4 ++-- src/filesplugin.js | 4 ---- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/Service/UI/FilesActionsMenuService.php b/lib/Service/UI/FilesActionsMenuService.php index 0c032510..9b23a0e3 100644 --- a/lib/Service/UI/FilesActionsMenuService.php +++ b/lib/Service/UI/FilesActionsMenuService.php @@ -57,7 +57,7 @@ public function registerFileActionMenu(string $appId, string $name, string $disp 'appid' => $appId, 'name' => $name, 'display_name' => $displayName, - 'action_handler' => $actionHandler, + 'action_handler' => ltrim($actionHandler, '/'), 'icon' => ltrim($icon, '/'), 'mime' => $mime, 'permissions' => $permissions, diff --git a/lib/Service/UI/ScriptsService.php b/lib/Service/UI/ScriptsService.php index 2b2dfd9b..5003b64b 100644 --- a/lib/Service/UI/ScriptsService.php +++ b/lib/Service/UI/ScriptsService.php @@ -31,7 +31,7 @@ public function setExAppScript(string $appId, string $type, string $name, string 'appid' => $appId, 'type' => $type, 'name' => $name, - 'path' => $path, + 'path' => ltrim($path, '/'), 'after_app_id' => $afterAppId, ]); if ($script !== null) { @@ -95,7 +95,7 @@ public function applyExAppScripts(string $appId, string $type, string $name): ar } else { Util::addScript(Application::APP_ID, $fakeJsPath, $value['after_app_id']); } - $mapResult[$i] = $appId . '/' . ltrim($value['path'], '/'); + $mapResult[$i] = $appId . '/' . $value['path']; $i++; } return $mapResult; diff --git a/lib/Service/UI/StylesService.php b/lib/Service/UI/StylesService.php index e5172866..eac66652 100644 --- a/lib/Service/UI/StylesService.php +++ b/lib/Service/UI/StylesService.php @@ -28,7 +28,7 @@ public function setExAppStyle(string $appId, string $type, string $name, string 'appid' => $appId, 'type' => $type, 'name' => $name, - 'path' => $path, + 'path' => ltrim($path, '/'), ]); if ($style !== null) { $newStyle->setId($style->getId()); @@ -79,7 +79,7 @@ public function deleteExAppStyles(string $appId): int { public function applyExAppStyles(string $appId, string $type, string $name): void { $styles = $this->mapper->findByAppIdTypeName($appId, $type, $name); foreach ($styles as $value) { - $path = 'proxy/'. $appId . '/' . ltrim($value['path'], '/'); + $path = 'proxy/'. $appId . '/' . $value['path']; Util::addStyle(Application::APP_ID, $path); } } diff --git a/src/filesplugin.js b/src/filesplugin.js index 05457753..f0eb4d56 100644 --- a/src/filesplugin.js +++ b/src/filesplugin.js @@ -26,10 +26,6 @@ function loadExAppInlineSvgIcon(appId, route) { } function generateAppAPIProxyUrl(appId, route) { - // truncate leading slash - if (route.startsWith('/')) { - route = route.substring(1) - } return generateUrl(`/apps/app_api/proxy/${appId}/${route}`) }