FriendsOfFlarum / upload

The file upload extension with insane intelligence for your Flarum forum.
https://discuss.flarum.org/d/4154
MIT License
175 stars 94 forks source link

MIME inspection tool #312

Closed clarkwinkelmann closed 2 years ago

clarkwinkelmann commented 2 years ago

Changes proposed in this pull request: Add a new utility to the admin panel where files can be dropped to see their MIME type and guessed extension.

Reviewers should focus on: The feature is mostly standalone. It re-uses the file repository but only to copy the file to the temporary folder. The file is never persisted to database or assets folder.

Are the labels explanatory enough? Is the placement of the test button good?

Screenshot Example with common file: image Example with fallback: image Button to access the tool is below MIME configuration: image

Confirmed

luceos commented 2 years ago

I absolutely love the idea, I'm not too sure about the implementation. It would, imo, make more sense to have a "adopt mimetype from uploaded sample" or "add mimetype entry from uploaded sample". What do you think?

clarkwinkelmann commented 2 years ago

I'm a bit worried people will insert dangerous MIME types in their configuration if it can be done in a single click without giving it any thought.

My main intent with the tool is that if someone has an issue, we can ask them to use it and share the output.

There's also always the issue that for some special file types, you will need to test multiple files to find all the MIME types that might be detected. And then this would have to be converted into a regex.

I was considering showing which of the saved configurations matches the given file, but I feel like it adds too much complexity. This extension is already quite complex so I was hoping to keep this as simple and isolated as possible so it doesn't give us trouble later on when we need to refactor other things :innocent:

clarkwinkelmann commented 2 years ago

Requesting @imorland 's feedback to decide if we should move forward with this feature