Skip to content
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

Validate image files vs simpleimage (and svg) #1051

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

ehawman-rosenberg
Copy link
Contributor

Closes #1048

Currently, if a file returns TRUE for isImage() (which checks vs mimetype), but isn't supported by SimpleImage, we get a broken link
CUPjBteTCt.

SimpleImage supports "gif", "jpg", "jpeg", "png", "webp", and "bmp" formats (also "jfif" which is just another jpg variant). We also have a way to handle svg file previews.

As such, I am validating whether an image is embeddable vs these extensions, and I've changed the structure of the preview generation in manage-files.php and template.php to generate the graceful /thumbnail-unavailable.png
lm09Kcbnie
image

Ultimately I'd like to keep isImage() filtering by mimetype and then have an exception from SimpleImage's failure to generate a thumbnail fail us over into a matching icon from danhendricks' file-icon-vectors.

However, I'm having trouble figuring out how to get Composer to download the package. What calls it and when? Putting it in composer.json hasn't worked.

"require": {
    "php": ">=7.0",
    "claviska/simpleimage": "~3",
    "enshrined/svg-sanitize": "^0.13",
    "moxiecode/plupload": "3.1.2",
    "paragonie/random_compat": "^2.0",
    "phpmailer/phpmailer": "~6.1",
    "tamtamchik/simple-flash": "^1.2",
    "hybridauth/hybridauth": "^3.0",
    "dmhendricks/file-icon-vectors": "^1.0"
}

What am I missing?

@ehawman-rosenberg
Copy link
Contributor Author

Apologies for all the fiddle-faddling. Again, I'm learning Git an GitKraken decided to whip me around. I was under the impression that if I branched from my fork of Develop, that the subsequent branches would inherit changes.

@ignacionelson
Copy link
Collaborator

No need to apologize! Thanks for your improvements!
You need to run composer install to get the new specified versions.
Gitkraken got a bit complicated for me, I feel more comfortable with github's own client. You can get a Linux version from here
https://github.com/shiftkey/desktop

@ehawman-rosenberg
Copy link
Contributor Author

So after some more testing, this doesn't let SVG files work. In fact, as far as I can tell r1335 isn't able to render SVGs in the manage-files page at all. It shows up as a broken link. This is running on a vanilla install (with the show SVG as thumbnail option enabled)
image

I can view /localhost/projectsend-r1335/vendor/dmhendricks/file-icon-vectors/dist/icons/square-o/7z.svg in Chrome.

Then, I upload it using ProjectSend's method.

/localhost/projectsend-r1335/upload/files/[uglyhash]-7z.svg throws an Internal Server Error.

Checking the logs shows
C:/xampp/htdocs/projectsend-r1335/upload/files/.htaccess: Expected </FilesMatch> but saw </Files>

Can you point me in the right direction on this? I only see a reference to FilesMatch in upload/files/.htaccess and upload/temp/.htaccess.

@ignacionelson
Copy link
Collaborator

ignacionelson commented Dec 29, 2021

EDIT: Sorry, not meant to ask why you added it as you've already explained that, but why is it in this version as it does not seem to be used yet.

Thanks for this! One question, why did you add dmhendricks/file-icon-vectors?

@ehawman-rosenberg
Copy link
Contributor Author

I should have started a new branch once I started going down the icons road. This current version handles SVGs, and serves up a "picture unavailable" placeholder when the file is an image that isn't in the hardcoded SimpleImage types list.

I've created another branch for catching SimpleImage exceptions and serving up the appropriate icon from the pack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unsupported image files fail to generate thumbnails (tif)
2 participants