Skip to content

File extensions config doesn't work properly for array #8687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
BartoszMarganiec opened this issue Jul 15, 2023 · 1 comment · Fixed by #8688
Closed
4 tasks done

File extensions config doesn't work properly for array #8687

BartoszMarganiec opened this issue Jul 15, 2023 · 1 comment · Fixed by #8688
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@BartoszMarganiec
Copy link
Contributor

New Issue Checklist

Issue Description

Adding specific file extension to Parse Server config under fileUpload.fileExtensions option doesn't work. When I upload quicktime file I get error with the code 130 and message "File upload of extension quicktime is disabled.".

I checked the code and I think there is a bug here: https://github.com/parse-community/parse-server/blob/c9b59719ec9648f9ba8bbef89db2a24a227ae55c/src/Routers/FilesRouter.js#L150C24-L150C24

Instead of

const regex = new RegExp(fileExtensions);

there should be

const regex = new RegExp(ext);

as fileExtensions is an array of patterns and every pattern should be tested separately.

Steps to reproduce

Set file upload config (standard extensions + quicktime extension):

{ fileUpload: { fileExtensions: ["^[^hH][^tT][^mM][^lL]?$", "^quicktime$"], }}

Actual Outcome

Parse Server doesn't allow me to upload quicktime file.

Expected Outcome

I should be able to add any extension.

Environment

Server

  • Parse Server version: 6.2.1
  • Operating system: MacOS Ventura 13.0.1
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 4.0.28
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): remote VPS

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): JavaScript (React-Native)
  • SDK version: 4.0.1
@parse-github-assistant
Copy link

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
2 participants