Commit 6ee78af7 authored by Vincent Petry's avatar Vincent Petry Committed by GitHub

Merge pull request #27269 from owncloud/upload_filter_issue7496_backend

#7496 Don`t allow upload of files with extension .part
parents ff126a53 67994452
......@@ -1402,6 +1402,12 @@ class OC_Util {
if (\OC\Files\Filesystem::isIgnoredDir($trimmed)) {
return false;
}
// detect part files
if (preg_match('/' . \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX . '/', $trimmed) !== 0) {
return false;
}
foreach (str_split($trimmed) as $char) {
if (strpos(\OCP\Constants::FILENAME_INVALID_CHARS, $char) !== false) {
return false;
......
......@@ -10,6 +10,9 @@ namespace Test;
use OC_Util;
/**
* @group DB
*/
class UtilTest extends \Test\TestCase {
public function testGetVersion() {
$version = \OCP\Util::getVersion();
......@@ -234,6 +237,13 @@ class UtilTest extends \Test\TestCase {
['.. ', false],
['. ', false],
[' .', false],
// part files not allowed
['.part', false],
['notallowed.part', false],
['neither.filepart', false],
// part in the middle is ok
['super movie part one.mkv', true],
['super.movie.part.mkv', true],
];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment