From 1e35a2877a201d356e3e1f0d3ae728d2dfdb5bed Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Mon, 14 Feb 2022 15:06:21 +0000 Subject: [PATCH] Issue #3264153 by neclimdul: Fix missing sprintf argument in CKEditor5ImageController --- .../src/Controller/CKEditor5ImageController.php | 2 +- .../tests/src/Functional/ImageUploadAccessTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php b/core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php index 9d4a6c674e9c..ba6cdce28b58 100644 --- a/core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php +++ b/core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php @@ -164,7 +164,7 @@ public function upload(Request $request) { $lock_id = $this->generateLockIdFromFileUri($file_uri); if (!$this->lock->acquire($lock_id)) { - throw new HttpException(503, sprintf('File "%s" is already locked for writing.'), NULL, ['Retry-After' => 1]); + throw new HttpException(503, sprintf('File "%s" is already locked for writing.', $file_uri), NULL, ['Retry-After' => 1]); } // Begin building file entity. diff --git a/core/modules/ckeditor5/tests/src/Functional/ImageUploadAccessTest.php b/core/modules/ckeditor5/tests/src/Functional/ImageUploadAccessTest.php index b6c99ebc1324..ba239cc17fa7 100644 --- a/core/modules/ckeditor5/tests/src/Functional/ImageUploadAccessTest.php +++ b/core/modules/ckeditor5/tests/src/Functional/ImageUploadAccessTest.php @@ -2,6 +2,9 @@ namespace Drupal\Tests\ckeditor5\Functional; +use Drupal\Component\Utility\Crypt; +use Drupal\Core\File\FileSystemInterface; + /** * Test image upload access. * @@ -42,6 +45,15 @@ public function testCkeditor5ImageUploadRoute() { $response = $this->uploadRequest($url, $test_image, 'test.jpg'); $this->assertSame(201, $response->getStatusCode()); + // Ensure lock failures are reported correctly. + $d = 'public://inline-images/test.jpg'; + $f = $this->container->get('file_system')->getDestinationFilename($d, FileSystemInterface::EXISTS_RENAME); + $this->container->get('lock') + ->acquire('file:ckeditor5:' . Crypt::hashBase64($f)); + $response = $this->uploadRequest($url, $test_image, 'test.jpg'); + $this->assertSame(503, $response->getStatusCode()); + $this->assertStringContainsString('File "public://inline-images/test_0.jpg" is already locked for writing.', (string) $response->getBody()); + // Ensure that users without permissions to the text format cannot upload // images. $this->drupalLogout(); -- GitLab