Skip to content

Commit

Permalink
Adjust check for php file extensions (#3681)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Davis <[email protected]>
  • Loading branch information
rmdavi and Ryan Davis authored Jul 26, 2024
1 parent d4aed99 commit 91a0aae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/MediaCollections/FileAdder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 6 additions & 0 deletions tests/MediaCollections/FileAdderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

0 comments on commit 91a0aae

Please sign in to comment.