From 877e3005bc3c1b9d172e2978dfd2b13951cc11b4 Mon Sep 17 00:00:00 2001 From: Sebastian Almberg <83243306+Sebbeben@users.noreply.github.com> Date: Fri, 6 Mar 2026 08:41:43 +0100 Subject: [PATCH] Fix download modal: use per-backup modals for CSP/Turbo compatibility - Replace shared modal + inline JS with per-backup modals that have filename pre-set in hidden fields (no JavaScript needed) - Add data-turbo="false" to download forms for native browser handling - Add data-bs-dismiss="modal" to submit button to auto-close modal - Add hidden username field for Chrome accessibility best practice - Fix test: GET on POST-only route returns 404 not 405 --- .../admin/update_manager/index.html.twig | 95 +++++++++---------- .../UpdateManagerControllerTest.php | 4 +- 2 files changed, 46 insertions(+), 53 deletions(-) diff --git a/templates/admin/update_manager/index.html.twig b/templates/admin/update_manager/index.html.twig index 7dcb813c..76d7ca2a 100644 --- a/templates/admin/update_manager/index.html.twig +++ b/templates/admin/update_manager/index.html.twig @@ -418,10 +418,9 @@
{% if not backup_download_disabled and is_granted('@system.manage_updates') %} @@ -457,6 +456,48 @@ {% endif %}
+ {% if not backup_download_disabled and is_granted('@system.manage_updates') %} + {# Per-backup download modal - no inline JS needed, CSP compatible with Turbo #} + + {% endif %} {% else %} @@ -477,52 +518,4 @@ -{# Password confirmation modal for backup download #} -{% if not backup_download_disabled and is_granted('@system.manage_updates') %} - - -{% endif %} {% endblock %} diff --git a/tests/Controller/UpdateManagerControllerTest.php b/tests/Controller/UpdateManagerControllerTest.php index c37d413e..0c2b2224 100644 --- a/tests/Controller/UpdateManagerControllerTest.php +++ b/tests/Controller/UpdateManagerControllerTest.php @@ -251,10 +251,10 @@ final class UpdateManagerControllerTest extends WebTestCase $client = static::createClient(); $this->loginAsAdmin($client); - // GET should return 405 Method Not Allowed + // GET returns 404 since no GET route exists for this path $client->request('GET', '/en/system/update-manager/backup/download'); - $this->assertResponseStatusCodeSame(405); + $this->assertResponseStatusCodeSame(404); } public function testDownloadBackupRequiresAuth(): void