diff --git a/spec/ParseFile.spec.js b/spec/ParseFile.spec.js index e36929636b..c7c58f8ad5 100644 --- a/spec/ParseFile.spec.js +++ b/spec/ParseFile.spec.js @@ -1364,6 +1364,18 @@ describe('Parse.File testing', () => { ); }); + it('default should allow common types', async () => { + await reconfigureServer({ + fileUpload: { + enableForPublic: true, + }, + }); + for (const type of ['plain', 'txt', 'png', 'jpg', 'gif', 'doc']) { + const file = new Parse.File(`parse-server-logo.${type}`, { base64: 'ParseA==' }); + await file.save(); + } + }); + it('works with a period in the file name', async () => { await reconfigureServer({ fileUpload: { diff --git a/src/Options/Definitions.js b/src/Options/Definitions.js index 6db0f51d3a..ee1137b7ea 100644 --- a/src/Options/Definitions.js +++ b/src/Options/Definitions.js @@ -1022,9 +1022,9 @@ module.exports.FileUploadOptions = { fileExtensions: { env: 'PARSE_SERVER_FILE_UPLOAD_FILE_EXTENSIONS', help: - "Sets the allowed file extensions for uploading files. The extension is defined as an array of file extensions, or a regex pattern.

It is recommended to restrict the file upload extensions as much as possible. HTML files are especially problematic as they may be used by an attacker who uploads a HTML form to look legitimate under your app's domain name, or to compromise the session token of another user via accessing the browser's local storage.

Defaults to `^[^hH][^tT][^mM][^lL]?$` which allows any file extension except HTML files.", + "Sets the allowed file extensions for uploading files. The extension is defined as an array of file extensions, or a regex pattern.

It is recommended to restrict the file upload extensions as much as possible. HTML files are especially problematic as they may be used by an attacker who uploads a HTML form to look legitimate under your app's domain name, or to compromise the session token of another user via accessing the browser's local storage.

Defaults to `^(?!(h|H)(t|T)(m|M)(l|L)?$)` which allows any file extension except HTML files.", action: parsers.arrayParser, - default: ['^[^hH][^tT][^mM][^lL]?$'], + default: ['^(?!(h|H)(t|T)(m|M)(l|L)?$)'], }, }; module.exports.DatabaseOptions = { diff --git a/src/Options/docs.js b/src/Options/docs.js index 98318d23ef..219fc2e5a9 100644 --- a/src/Options/docs.js +++ b/src/Options/docs.js @@ -229,7 +229,7 @@ * @property {Boolean} enableForAnonymousUser Is true if file upload should be allowed for anonymous users. * @property {Boolean} enableForAuthenticatedUser Is true if file upload should be allowed for authenticated users. * @property {Boolean} enableForPublic Is true if file upload should be allowed for anyone, regardless of user authentication. - * @property {String[]} fileExtensions Sets the allowed file extensions for uploading files. The extension is defined as an array of file extensions, or a regex pattern.

It is recommended to restrict the file upload extensions as much as possible. HTML files are especially problematic as they may be used by an attacker who uploads a HTML form to look legitimate under your app's domain name, or to compromise the session token of another user via accessing the browser's local storage.

Defaults to `^[^hH][^tT][^mM][^lL]?$` which allows any file extension except HTML files. + * @property {String[]} fileExtensions Sets the allowed file extensions for uploading files. The extension is defined as an array of file extensions, or a regex pattern.

It is recommended to restrict the file upload extensions as much as possible. HTML files are especially problematic as they may be used by an attacker who uploads a HTML form to look legitimate under your app's domain name, or to compromise the session token of another user via accessing the browser's local storage.

Defaults to `^(?!(h|H)(t|T)(m|M)(l|L)?$)` which allows any file extension except HTML files. */ /** diff --git a/src/Options/index.js b/src/Options/index.js index 40187cb64b..067ac15ff3 100644 --- a/src/Options/index.js +++ b/src/Options/index.js @@ -576,8 +576,8 @@ export interface PasswordPolicyOptions { } export interface FileUploadOptions { - /* Sets the allowed file extensions for uploading files. The extension is defined as an array of file extensions, or a regex pattern.

It is recommended to restrict the file upload extensions as much as possible. HTML files are especially problematic as they may be used by an attacker who uploads a HTML form to look legitimate under your app's domain name, or to compromise the session token of another user via accessing the browser's local storage.

Defaults to `^[^hH][^tT][^mM][^lL]?$` which allows any file extension except HTML files. - :DEFAULT: ["^[^hH][^tT][^mM][^lL]?$"] */ + /* Sets the allowed file extensions for uploading files. The extension is defined as an array of file extensions, or a regex pattern.

It is recommended to restrict the file upload extensions as much as possible. HTML files are especially problematic as they may be used by an attacker who uploads a HTML form to look legitimate under your app's domain name, or to compromise the session token of another user via accessing the browser's local storage.

Defaults to `^(?!(h|H)(t|T)(m|M)(l|L)?$)` which allows any file extension except HTML files. + :DEFAULT: ["^(?!(h|H)(t|T)(m|M)(l|L)?$)"] */ fileExtensions: ?(string[]); /* Is true if file upload should be allowed for anonymous users. :DEFAULT: false */