Relax restrictions on MediaLibrary filenames (#3778)
Fixes #3741. Credit to @chrisbethelepb
This commit is contained in:
parent
cf9d487b30
commit
0ffdbc5efd
|
|
@ -475,7 +475,23 @@ class MediaLibrary
|
|||
/*
|
||||
* Validate folder names
|
||||
*/
|
||||
if (!preg_match('/^[\w@\.\s_\-\/]+$/iu', $path)) {
|
||||
$regexWhitelist = [
|
||||
'\w', // any word character
|
||||
preg_quote('@', '/'),
|
||||
preg_quote('.', '/'),
|
||||
'\s', // whitespace character
|
||||
preg_quote('-', '/'),
|
||||
preg_quote('_', '/'),
|
||||
preg_quote('/', '/'),
|
||||
preg_quote('(', '/'),
|
||||
preg_quote(')', '/'),
|
||||
preg_quote('[', '/'),
|
||||
preg_quote(']', '/'),
|
||||
preg_quote(',', '/'),
|
||||
preg_quote('=', '/'),
|
||||
];
|
||||
|
||||
if (!preg_match('/^[' . implode('', $regexWhitelist) . ']+$/iu', $path)) {
|
||||
throw new ApplicationException(Lang::get('system::lang.media.invalid_path', compact('path')));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ class MediaLibraryTest extends TestCase // @codingStandardsIgnoreLine
|
|||
['file.ext'],
|
||||
['file..ext'],
|
||||
['file...ext'],
|
||||
['one,two.ext'],
|
||||
['one(two)[].ext'],
|
||||
['one=(two)[].ext'],
|
||||
['one_(two)[].ext'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue