Support additional file name and path characters in media manager (#4564)

* Support additional file name and path characters in media manager

When working with abstract file names that may contain additional characters, such as quotes or ampersands, the media manager would throw an error. This PR adds two additional characters to the character whitelist.

* Add unicode filename to tests
This commit is contained in:
Larry Barker 2019-12-05 02:44:04 -06:00 committed by Samuel Georges
parent 9dc54baddd
commit 2b05d01c6c
2 changed files with 7 additions and 0 deletions

View File

@ -486,6 +486,8 @@ class MediaLibrary
preg_quote(']', '/'), preg_quote(']', '/'),
preg_quote(',', '/'), preg_quote(',', '/'),
preg_quote('=', '/'), preg_quote('=', '/'),
preg_quote("'", '/'),
preg_quote('&', '/'),
]; ];
if (!preg_match('/^[' . implode('', $regexWhitelist) . ']+$/iu', $path)) { if (!preg_match('/^[' . implode('', $regexWhitelist) . ']+$/iu', $path)) {

View File

@ -37,6 +37,11 @@ class MediaLibraryTest extends TestCase // @codingStandardsIgnoreLine
['one(two)[].ext'], ['one(two)[].ext'],
['one=(two)[].ext'], ['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'],
]; ];
} }