Node.js based forum software built for the modern web
better checks for file extensions
barisusaklic98bd8733497
diff --git a/src/file.js b/src/file.jsindex 6be1cd37c8..b9fe29881a 100644--- a/src/file.js+++ b/src/file.js@@ -46,10 +46,6 @@ file.isFileTypeAllowed = function(path, allowedExtensions, callback) {return callback();}- allowedExtensions = allowedExtensions.filter(Boolean).map(function(extension) {- return extension.trim();- });-var magic = new Magic(mmmagic.MAGIC_MIME_TYPE);magic.detectFile(path, function(err, mimeType) {if (err) {@@ -72,6 +68,14 @@ file.allowedExtensions = function() {return [];}allowedExtensions = allowedExtensions.split(',');+ allowedExtensions = allowedExtensions.filter(Boolean).map(function(extension) {+ extension = extension.trim();+ return extension.replace(/\./g, '');+ });+ if (allowedExtensions.indexOf('jpg') !== -1 && allowedExtensions.indexOf('jpeg') === -1) {+ allowedExtensions.push('jpeg');+ }+ console.log(allowedExtensions)return allowedExtensions;};diff --git a/src/views/admin/settings/post.tpl b/src/views/admin/settings/post.tplindex b669021204..833b98fd6f 100644--- a/src/views/admin/settings/post.tpl+++ b/src/views/admin/settings/post.tpl@@ -140,7 +140,7 @@</div><strong>Topic Thumb Size</strong><br /> <input type="text" class="form-control" value="120" data-field="topicThumbSize"> <br />- <strong>Allowed file types, (ie png, pdf, zip). Leave empty to allow all.</strong><br /> <input type="text" class="form-control" value="" data-field="allowedFileExtensions"><br />+ <strong>Allowed file types, (ie png, jpg, pdf, zip). Leave empty to allow all.</strong><br /> <input type="text" class="form-control" value="" data-field="allowedFileExtensions"><br /></form></div>