From bc67ae21980648a25c7883b3770c21dc53f4761e Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 16 Oct 2023 01:19:54 +0300 Subject: [PATCH] require allowed locales in routing requests --- src/Controller/ActivityController.php | 12 ++++-------- src/Controller/TorrentController.php | 28 +++++++++++++++++++++++---- src/Controller/UserController.php | 16 +++++++-------- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/Controller/ActivityController.php b/src/Controller/ActivityController.php index 643371e..2f62d78 100644 --- a/src/Controller/ActivityController.php +++ b/src/Controller/ActivityController.php @@ -17,6 +17,9 @@ class ActivityController extends AbstractController #[Route( '/{_locale}/activity', name: 'activity_all', + requirements: [ + '_locale' => '%app.locales%' + ], methods: [ 'GET' @@ -64,9 +67,6 @@ class ActivityController extends AbstractController #[Route( '/{_locale}/rss/activity', name: 'rss_activity', - defaults: [ - '_locale' => '%app.locale%' - ], requirements: [ '_locale' => '%app.locales%' ], @@ -112,7 +112,6 @@ class ActivityController extends AbstractController '/{_locale}/rss/activity/user/{userId}', name: 'rss_activity_user', defaults: [ - '_locale' => '%app.locale%', 'userId' => 0 ], requirements: [ @@ -170,11 +169,8 @@ class ActivityController extends AbstractController #[Route( '/{_locale}/rss/activity/torrent/{torrentId}', name: 'rss_activity_torrent', - defaults: [ - '_locale' => '%app.locale%', - ], requirements: [ - '_locale' => '%app.locales%', + '_locale' => '%app.locales%', 'torrentId' => '\d+' ], methods: diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php index 78edd63..a328cbc 100644 --- a/src/Controller/TorrentController.php +++ b/src/Controller/TorrentController.php @@ -21,6 +21,7 @@ class TorrentController extends AbstractController name: 'torrent_info', requirements: [ + '_locale' => '%app.locales%', 'torrentId' => '\d+', ], methods: @@ -201,6 +202,10 @@ class TorrentController extends AbstractController #[Route( '/{_locale}/search', name: 'torrent_search', + requirements: + [ + '_locale' => '%app.locales%' + ], methods: [ 'GET' @@ -362,6 +367,10 @@ class TorrentController extends AbstractController #[Route( '/{_locale}', name: 'torrent_recent', + requirements: + [ + '_locale' => '%app.locales%' + ], methods: [ 'GET' @@ -515,9 +524,6 @@ class TorrentController extends AbstractController #[Route( '/{_locale}/rss/torrents', name: 'rss_torrents_recent', - defaults: [ - '_locale' => '%app.locale%' - ], requirements: [ '_locale' => '%app.locales%' ], @@ -596,6 +602,10 @@ class TorrentController extends AbstractController #[Route( '/{_locale}/submit', name: 'torrent_submit', + requirements: + [ + '_locale' => '%app.locales%' + ], methods: [ 'GET', @@ -746,6 +756,7 @@ class TorrentController extends AbstractController name: 'torrent_approve_toggle', requirements: [ + '_locale' => '%app.locales%', 'torrentId' => '\d+', ], methods: @@ -822,6 +833,7 @@ class TorrentController extends AbstractController name: 'torrent_locales_edit', requirements: [ + '_locale' => '%app.locales%', 'torrentId' => '\d+', 'torrentLocalesId' => '\d+', ], @@ -1021,6 +1033,7 @@ class TorrentController extends AbstractController name: 'torrent_locales_approve', requirements: [ + '_locale' => '%app.locales%', 'torrentId' => '\d+', 'torrentLocalesId' => '\d+', ], @@ -1107,6 +1120,7 @@ class TorrentController extends AbstractController name: 'torrent_locales_delete', requirements: [ + '_locale' => '%app.locales%', 'torrentId' => '\d+', 'torrentLocalesId' => '\d+', ], @@ -1181,7 +1195,8 @@ class TorrentController extends AbstractController name: 'torrent_sensitive_edit', requirements: [ - 'torrentId' => '\d+', + '_locale' => '%app.locales%', + 'torrentId' => '\d+', 'torrentSensitiveId' => '\d+', ], defaults: @@ -1350,6 +1365,7 @@ class TorrentController extends AbstractController name: 'torrent_sensitive_approve', requirements: [ + '_locale' => '%app.locales%', 'torrentId' => '\d+', 'torrentSensitiveId' => '\d+', ], @@ -1436,6 +1452,7 @@ class TorrentController extends AbstractController name: 'torrent_sensitive_delete', requirements: [ + '_locale' => '%app.locales%', 'torrentId' => '\d+', 'torrentSensitiveId' => '\d+', ], @@ -1510,6 +1527,7 @@ class TorrentController extends AbstractController name: 'torrent_star_toggle', requirements: [ + '_locale' => '%app.locales%', 'torrentId' => '\d+', ], methods: @@ -1588,6 +1606,7 @@ class TorrentController extends AbstractController name: 'torrent_download_file', requirements: [ + '_locale' => '%app.locales%', 'torrentId' => '\d+', ], methods: @@ -1708,6 +1727,7 @@ class TorrentController extends AbstractController name: 'torrent_download_magnet', requirements: [ + '_locale' => '%app.locales%', 'torrentId' => '\d+', ], methods: diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 574a1e4..4b75626 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -40,9 +40,6 @@ class UserController extends AbstractController #[Route( '/{_locale}/settings', name: 'user_settings', - defaults: [ - '_locale' => '%app.locale%' - ], requirements: [ '_locale' => '%app.locales%', ], @@ -157,7 +154,6 @@ class UserController extends AbstractController '/{_locale}/profile/{userId}', name: 'user_info', defaults: [ - '_locale' => '%app.locale%', 'userId' => 0, ], requirements: [ @@ -265,7 +261,8 @@ class UserController extends AbstractController name: 'user_star_toggle', requirements: [ - 'userId' => '\d+', + '_locale' => '%app.locales%', + 'userId' => '\d+', ], methods: [ @@ -341,7 +338,8 @@ class UserController extends AbstractController name: 'user_moderator_toggle', requirements: [ - 'userId' => '\d+', + '_locale' => '%app.locales%', + 'userId' => '\d+', ], methods: [ @@ -415,7 +413,8 @@ class UserController extends AbstractController name: 'user_status_toggle', requirements: [ - 'userId' => '\d+', + '_locale' => '%app.locales%', + 'userId' => '\d+', ], methods: [ @@ -489,7 +488,8 @@ class UserController extends AbstractController name: 'user_approved_toggle', requirements: [ - 'userId' => '\d+', + '_locale' => '%app.locales%', + 'userId' => '\d+', ], methods: [