v0.1 add check mimetype if mimetype of file is undefined

This commit is contained in:
Miloš Holba
2020-09-06 20:29:16 +02:00
committed by Peter Papp
parent f3254a380f
commit 0d7b920cbe
5 changed files with 13 additions and 10 deletions

View File

@@ -25,9 +25,9 @@ class MimetypeBlacklistValidation implements Rule
public function passes($attribute, $value)
{
$mimetype_blacklist = explode(',' ,get_setting('mimetypes_blacklist'));
$fileMimetype = explode('/' ,$value->getMimeType());
return !array_intersect($fileMimetype , $mimetype_blacklist);
$file_mimetype = explode('/' ,$value->getMimeType());
return !array_intersect($file_mimetype , $mimetype_blacklist);
}
/**

View File

@@ -10,7 +10,7 @@ const Helpers = {
Vue.prototype.$updateText = debounce(function (route, name, value) {
if (value === '') return
// if (value === '') return
axios.post(this.$store.getters.api + route, {name, value, _method: 'patch'})
.catch(error => {
@@ -283,14 +283,17 @@ const Helpers = {
Vue.prototype.$checkFileMimetype = function(files) {
let validated = true
let mimetypesBlacklist = store.getters.config.mimetypesBlacklist
console.log(files[0])
for (let i = 0 ; i<files.length; i++ ) {
let fileType = files[i].type.split("/")
let fileType = files[i].type.split("/")
if(!fileType[0]) {
fileType[1] = _.last(files[i].name.split('.'))
}
if(mimetypesBlacklist.includes(fileType[1])) {
validated = false
events.$emit('alert:open', {
emoji: '😬',
title: i18n.t('popup_mimetypes_blacklist.title'),

View File

@@ -210,7 +210,7 @@
"others": {
"mimetypes_blacklist": "Mimetypes Blacklist",
"mimetypes_blacklist_plac":"Add mimetypes to Blacklist" ,
"mimetypes_blacklist_help" :"If you want ban some type of files to upload just add them to blacklist like this: php,mp3,jpeg <br/> Use a comma between each mime type. Don't use a dot before mimetypes." ,
"mimetypes_blacklist_help" :"If you want ban some type of files to upload just add them to blacklist like this: x-php,mp3,jpeg <br/> Use a comma between each mime type. Don't use a dot before mimetypes." ,
"section_cache": "Application Cache",
"cache_disclaimer": "Did you change anything in your .env file or change your stripe credentials? Then clear your cache.",
"cache_clear": "Clear Cache",

View File

@@ -212,7 +212,7 @@
"others": {
"mimetypes_blacklist": "Mimetypes Blacklist",
"mimetypes_blacklist_plac":"Add mimetypes to Blacklist" ,
"mimetypes_blacklist_help" :"If you want ban some type of files to upload just add them to blacklist like this: php,mp3,jpeg <br/> Use a comma between each mime type. Don't use a dot before mimetypes." ,
"mimetypes_blacklist_help" :"If you want ban some type of files to upload just add them to blacklist like this: x-php,mp3,jpeg <br/> Use a comma between each mime type. Don't use a dot before mimetypes." ,
"section_cache": "Application Cache",
"cache_disclaimer": "Did you change anything in your .env file or change your Stripe credentials? Then clear your cache.",
"cache_clear": "Clear Cache",

View File

@@ -212,7 +212,7 @@
"others": {
"mimetypes_blacklist": "Čierna listina mimetypov",
"mimetypes_blacklist_plac":"Pridajte mimetypy do Čiernej listiny",
"mimetypes_blacklist_help" :"Ak chcete zakázať nahrávanie niektorých typov súborov, jednoducho ich pridajte na čiernu listinu, príklad: php, mp3, jpeg <br/> Medzi mimetypmi použite čiarku. Nevkladajte bodku pred mimetyp." ,
"mimetypes_blacklist_help" :"Ak chcete zakázať nahrávanie niektorých typov súborov, jednoducho ich pridajte na čiernu listinu, príklad: x-php, mp3, jpeg <br/> Medzi mimetypmi použite čiarku. Nevkladajte bodku pred mimetyp." ,
"section_cache": "Aplikačná pamäť",
"cache_disclaimer": "Zmenili ste niečo v .env súbore alebo ste zmenili Stripe poverenia? Vymažte aplikačnú pamäť.",
"cache_clear": "Vymazať aplikačnú pamäť",