Open klonos opened 1 year ago
PR up for review: https://github.com/backdrop/backdrop/pull/4479
In user_validate_picture()
we were specifying multiple validators, one of which is 'file_validate_is_image'
. file_validate_is_image()
, which is what this validator calls, is throwing the "Only images with the following extensions are allowed" error. In file_save_upload()
though, we are adding a 'file_validate_extensions'
validator when one has not been explicitly added (which is true for user_validate_picture()
), and that is what eventually throws the second "Only files with the following extensions are allowed" error. So the PR is checking if 'file_validate_is_image'
exists in the list of validators, and if that is the case, it skips adding a 'file_validate_extensions'
validator on top of that.
Yes, those errors are quite confusing, especially because they seem to suggest that a .doc file is acceptable as image. (I know that Unix-like systems do not use the extension to recognize the file type, but saying file with .doc extension is understood as Word file by most people.)
(As side note, if I were to upload an image to use for my user account, I would immediately select the .face file on my computer, which is a PNG image, and its purpose is exactly to "represent" me on my computer. The second validator would tell me that a file with .doc extension is acceptable, but a file with .face extension is not. 😅)
This is a follow-up to #4937 and #5917.
Steps To Reproduce
/admin/config/people/settings
, and make sure that the "Enable user pictures" setting is enabled (enable it and save the settings if not).Actual behavior
A validation error is thrown 👍🏼 ...however only the first item in the error is relevant:
Here's the same error in textual format:
Expected behavior
The second bullet point in the error should not be thrown, as the field only allows for images - not any type of supported document/file types.