diff --git a/modules/system/classes/MediaLibrary.php b/modules/system/classes/MediaLibrary.php index 645825750..93b6fe58f 100644 --- a/modules/system/classes/MediaLibrary.php +++ b/modules/system/classes/MediaLibrary.php @@ -486,6 +486,8 @@ class MediaLibrary preg_quote(']', '/'), preg_quote(',', '/'), preg_quote('=', '/'), + preg_quote("'", '/'), + preg_quote('&', '/'), ]; if (!preg_match('/^[' . implode('', $regexWhitelist) . ']+$/iu', $path)) { diff --git a/tests/unit/system/classes/MediaLibraryTest.php b/tests/unit/system/classes/MediaLibraryTest.php index 55c027544..24bab1567 100644 --- a/tests/unit/system/classes/MediaLibraryTest.php +++ b/tests/unit/system/classes/MediaLibraryTest.php @@ -37,6 +37,11 @@ class MediaLibraryTest extends TestCase // @codingStandardsIgnoreLine ['one(two)[].ext'], ['one=(two)[].ext'], ['one_(two)[].ext'], + /* + Example of a unicode-based filename with a single quote + @see: https://github.com/octobercms/october/pull/4564 + */ + ['BG中国通讯期刊(Blend\'r)创刊号.pdf'], ]; }