Add ignore_files to config,
test files against ignore_files list on upload fix typo and indentation Move blacklist declaration to lib/public/Files/FileInfo.php, Rename *ignored to *blacklisted Mocked blacklist_files for testing Mocked blacklist_files for testing Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
528a903a7b
commit
11f838f9e4
|
@ -101,7 +101,10 @@
|
||||||
throw t('files', '"{name}" is an invalid file name.', {name: name});
|
throw t('files', '"{name}" is an invalid file name.', {name: name});
|
||||||
} else if (trimmedName.length === 0) {
|
} else if (trimmedName.length === 0) {
|
||||||
throw t('files', 'File name cannot be empty.');
|
throw t('files', 'File name cannot be empty.');
|
||||||
|
} else if (OC.fileIsBlacklisted(trimmedName)) {
|
||||||
|
throw t('files', '"{name}" is not an allow filetype', {name: name});
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
displayStorageWarnings: function() {
|
displayStorageWarnings: function() {
|
||||||
|
|
|
@ -58,7 +58,9 @@ describe('OCA.Files.Files tests', function() {
|
||||||
' ..',
|
' ..',
|
||||||
'.. ',
|
'.. ',
|
||||||
'. ',
|
'. ',
|
||||||
' .'
|
' .',
|
||||||
|
'foo.part',
|
||||||
|
'bar.filepart'
|
||||||
];
|
];
|
||||||
for ( var i = 0; i < fileNames.length; i++ ) {
|
for ( var i = 0; i < fileNames.length; i++ ) {
|
||||||
var threwException = false;
|
var threwException = false;
|
||||||
|
|
|
@ -224,6 +224,14 @@ var OCP = {},
|
||||||
return link;
|
return link;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a user file is allowed to be handled.
|
||||||
|
* @param {string} file to check
|
||||||
|
*/
|
||||||
|
fileIsBlacklisted: function(file) {
|
||||||
|
return !!(file.match(oc_config.blacklist_files_regex));
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirect to the target URL, can also be used for downloads.
|
* Redirect to the target URL, can also be used for downloads.
|
||||||
* @param {string} targetURL URL to redirect to
|
* @param {string} targetURL URL to redirect to
|
||||||
|
|
|
@ -94,7 +94,8 @@ window.oc_appswebroots = {
|
||||||
};
|
};
|
||||||
window.oc_config = {
|
window.oc_config = {
|
||||||
session_lifetime: 600 * 1000,
|
session_lifetime: 600 * 1000,
|
||||||
session_keepalive: false
|
session_keepalive: false,
|
||||||
|
blacklist_files_regex: '\.(part|filepart)$',
|
||||||
};
|
};
|
||||||
window.oc_appconfig = {
|
window.oc_appconfig = {
|
||||||
core: {}
|
core: {}
|
||||||
|
|
|
@ -209,6 +209,7 @@ class JSConfigHelper {
|
||||||
'modRewriteWorking' => ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'),
|
'modRewriteWorking' => ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'),
|
||||||
'sharing.maxAutocompleteResults' => intval($this->config->getSystemValue('sharing.maxAutocompleteResults', 0)),
|
'sharing.maxAutocompleteResults' => intval($this->config->getSystemValue('sharing.maxAutocompleteResults', 0)),
|
||||||
'sharing.minSearchStringLength' => intval($this->config->getSystemValue('sharing.minSearchStringLength', 0)),
|
'sharing.minSearchStringLength' => intval($this->config->getSystemValue('sharing.minSearchStringLength', 0)),
|
||||||
|
'blacklist_files_regex' => \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX,
|
||||||
]),
|
]),
|
||||||
"oc_appconfig" => json_encode([
|
"oc_appconfig" => json_encode([
|
||||||
'core' => [
|
'core' => [
|
||||||
|
|
|
@ -63,6 +63,12 @@ interface FileInfo {
|
||||||
*/
|
*/
|
||||||
const MIMETYPE_FOLDER = 'httpd/unix-directory';
|
const MIMETYPE_FOLDER = 'httpd/unix-directory';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX Return regular expression to test filenames against (blacklisting)
|
||||||
|
* @since 12.0.0
|
||||||
|
*/
|
||||||
|
const BLACKLIST_FILES_REGEX = '\.(part|filepart)$';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Etag of the file or folder
|
* Get the Etag of the file or folder
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue