diff --git a/src/MediaCollections/FileAdder.php b/src/MediaCollections/FileAdder.php index bb3bf8111..a522ab91d 100644 --- a/src/MediaCollections/FileAdder.php +++ b/src/MediaCollections/FileAdder.php @@ -405,7 +405,7 @@ public function defaultSanitizer(string $fileName): string $sanitizedFileName = str_replace(['#', '/', '\\', ' '], '-', $sanitizedFileName); $phpExtensions = [ - 'php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar', + '.php', '.php3', '.php4', '.php5', '.php7', '.php8', '.phtml', '.phar', ]; if (Str::endsWith(strtolower($sanitizedFileName), $phpExtensions)) { diff --git a/tests/MediaCollections/FileAdderTest.php b/tests/MediaCollections/FileAdderTest.php index 46254f61c..e762e1b6b 100644 --- a/tests/MediaCollections/FileAdderTest.php +++ b/tests/MediaCollections/FileAdderTest.php @@ -30,3 +30,9 @@ $adder->defaultSanitizer('filename.php‎'); })->throws(FileNameNotAllowed::class); + +it('will not throw an exception if the sanitized file name ends with php but is not a php file', function () { + $adder = app(FileAdder::class); + + $adder->defaultSanitizer('media-libraryJQwPHp'); +})->throwsNoExceptions();