FriendsOfFlarum / upload

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

Uploading files of this type is not allowed #269

Closed lhunath closed 1 month ago

lhunath commented 3 years ago

Not sure why – but when I try to upload an image, the extension says: Uploading files of this type is not allowed

The image in question:

-rw-r--r--@ 1 lhunath  staff   115K  1 Mar 17:09 /Users/lhunath/Downloads/banner.jpg
$ file --mime-type /Users/lhunath/Downloads/banner.jpg
/Users/lhunath/Downloads/banner.jpg: image/jpeg
$ file /Users/lhunath/Downloads/banner.jpg
/Users/lhunath/Downloads/banner.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 72x72, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=4, PhotometricIntepretation=RGB, orientation=upper-left, resolutionunit=2], baseline, precision 8, 1170x572, components 3

The image is smaller than my upload limit.

I've tried changing the mime type configuration:

Not sure what's going on.

FWIW: I'm using freeflarum.com

lhunath commented 3 years ago

FYI, there is nothing in the server logs regarding this issue as reported by freeflarum.com (see https://github.com/gwillem/freeflarum.com/issues/195). That likely leaves the extension itself to be the culprit.

ghost commented 3 years ago

I would rather instead want an option to allow any file type

orschiro commented 2 years ago

I am having the same issue when pasting an image directly from the clipboard.

image

See also this video: https://drive.google.com/file/u/2/d/1cwE_Qi9XG1ei55v0OOgu9M8_PnSNSjoi/view

HideCM commented 2 years ago

Anyone can fix this case? me get this error too

luceos commented 2 years ago

This is always an issue with your regex or a different mimetype.

lhunath commented 2 years ago

@luceos if you'd like to ignore this issue, as maintainer of the project, feel free, of course. Though with that said, your justification for closing this issue does not live up to the details of the issue; which means that you are likely only turning a blind eye to a real bug in the code.

Consider that in the OP, https://github.com/FriendsOfFlarum/upload/issues/269#issue-819431975, the regular expression patterns tried are perfectly valid regex, some even in the BRE language superset and furthermore, the image in question has had its mime-type tested (using file) to ensure it was indeed recognized as an image.

Far be it from me to judge how you deal with issues that have been open for a long time, but if you want to just get rid of it, simply closing the GitHub issue without addressing the underlying concern is likely to just result in future complaints or an unstable extension.

luceos commented 2 years ago

If others can upload jpegs with this extension just fine, it is most likely a regex or server configuration thing.

I'd love to help dive into this, by the way.

So please provide the image in question if this is specific to one image, provide the PHP information, including gd version and a screenshot of the fof upload regex and adapter in use.

clarkwinkelmann commented 2 years ago

Use the "Test file MIME type" tool accessible below the MIME configuration in the admin panel to inspect the file using the same libraries that FoF Upload will use against actual uploads. That tool is available since version 1.2.0 of the extension. You can share a screenshot of the output with us.

The test tool can't help with pasted files directly, you would have to save the paste data to a binary file first, then upload that file.

If allowing all MIME types doesn't solve it, it's possible the file contains some "magic" numbers that identify it as an executable file that's blacklisted completely.

*

This likely won't do anything useful in a regular expression. It'll just match the character * since there's no character before it to modify. . is the match-any-single character in a regular expression. * is the zero to many modifier.

aggrovated commented 1 year ago

I'm still getting this error.... no solution?

DavideIadeluca commented 1 month ago

@lhunath @HideCM @aggrovated As @luceos mentioned, getting the error you mentioned most likely indicates an incorrect MIME type configuration or issues with the underlying server infrastructure. See the following working config:

^image\/.* (video\/(avi|mov|mp4|mpeg|quicktime|webm))|(audio\/(mpeg|mp4|mp3))|(image\/(gif|jpeg|png|tiff))|(application\/(pdf)) (application\/pdf) (application\/gzip) (application\/zip)

Settings

If you are still running into issues, please ask a new question at https://discuss.flarum.org/t/support where members of the community will gladly help out.

As this issue is neither a bug nor a feature request, it will be closed.