Skip to content

Commit 2760381

Browse files
authored
fix: Parse Server option fileExtensions default value rejects file extensions that are less than 3 or more than 4 characters long (#8699)
1 parent 3fbd926 commit 2760381

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

spec/ParseFile.spec.js

+12
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,18 @@ describe('Parse.File testing', () => {
13641364
);
13651365
});
13661366

1367+
it('default should allow common types', async () => {
1368+
await reconfigureServer({
1369+
fileUpload: {
1370+
enableForPublic: true,
1371+
},
1372+
});
1373+
for (const type of ['plain', 'txt', 'png', 'jpg', 'gif', 'doc']) {
1374+
const file = new Parse.File(`parse-server-logo.${type}`, { base64: 'ParseA==' });
1375+
await file.save();
1376+
}
1377+
});
1378+
13671379
it('works with a period in the file name', async () => {
13681380
await reconfigureServer({
13691381
fileUpload: {

src/Options/Definitions.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1022,9 +1022,9 @@ module.exports.FileUploadOptions = {
10221022
fileExtensions: {
10231023
env: 'PARSE_SERVER_FILE_UPLOAD_FILE_EXTENSIONS',
10241024
help:
1025-
"Sets the allowed file extensions for uploading files. The extension is defined as an array of file extensions, or a regex pattern.<br><br>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.<br><br>Defaults to `^[^hH][^tT][^mM][^lL]?$` which allows any file extension except HTML files.",
1025+
"Sets the allowed file extensions for uploading files. The extension is defined as an array of file extensions, or a regex pattern.<br><br>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.<br><br>Defaults to `^(?!(h|H)(t|T)(m|M)(l|L)?$)` which allows any file extension except HTML files.",
10261026
action: parsers.arrayParser,
1027-
default: ['^[^hH][^tT][^mM][^lL]?$'],
1027+
default: ['^(?!(h|H)(t|T)(m|M)(l|L)?$)'],
10281028
},
10291029
};
10301030
module.exports.DatabaseOptions = {

src/Options/docs.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Options/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ export interface PasswordPolicyOptions {
576576
}
577577

578578
export interface FileUploadOptions {
579-
/* Sets the allowed file extensions for uploading files. The extension is defined as an array of file extensions, or a regex pattern.<br><br>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.<br><br>Defaults to `^[^hH][^tT][^mM][^lL]?$` which allows any file extension except HTML files.
580-
:DEFAULT: ["^[^hH][^tT][^mM][^lL]?$"] */
579+
/* Sets the allowed file extensions for uploading files. The extension is defined as an array of file extensions, or a regex pattern.<br><br>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.<br><br>Defaults to `^(?!(h|H)(t|T)(m|M)(l|L)?$)` which allows any file extension except HTML files.
580+
:DEFAULT: ["^(?!(h|H)(t|T)(m|M)(l|L)?$)"] */
581581
fileExtensions: ?(string[]);
582582
/* Is true if file upload should be allowed for anonymous users.
583583
:DEFAULT: false */

0 commit comments

Comments
 (0)