From e663609647536ec799f3f5477cd232d83f1685fa Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Mon, 15 Jul 2024 10:59:19 +0200 Subject: [PATCH] do not allow php files --- .../Exceptions/FileNameNotAllowed.php | 13 +++++++++++++ src/MediaCollections/FileAdder.php | 17 +++++++++++++++-- tests/MediaCollections/FileAdderTest.php | 7 +++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/MediaCollections/Exceptions/FileNameNotAllowed.php diff --git a/src/MediaCollections/Exceptions/FileNameNotAllowed.php b/src/MediaCollections/Exceptions/FileNameNotAllowed.php new file mode 100644 index 000000000..b770af5c7 --- /dev/null +++ b/src/MediaCollections/Exceptions/FileNameNotAllowed.php @@ -0,0 +1,13 @@ +defaultSanitizer('Scan-‎9‎.‎14‎.‎2022-‎7‎.‎23‎.‎28.pdf')) ->toEqual('Scan-9.14.2022-7.23.28.pdf'); }); + +it('will throw an exception if the sanitized file name is a php file name', function() { + $adder = app(FileAdder::class); + + $adder->defaultSanitizer('filename.php‎'); +})->throws(FileNameNotAllowed::class);