-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix DNG/RAW Upload Error #5543
Fix DNG/RAW Upload Error #5543
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thabks for working on this. I took a glance at the change. I suppose we still need to support more formats.
app/src/main/java/fr/free/nrw/commons/customselector/ui/selector/ImageFileLoader.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/fr/free/nrw/commons/filepicker/FilePicker.java
Outdated
Show resolved
Hide resolved
@sivaraam Made the changes according to the supported formats mentioned on the webpage, Please Review it |
|
||
val extension = path.substringAfterLast(".", "") | ||
// Check if the extension is one of the allowed types | ||
if (extension.lowercase(Locale.ROOT) in arrayOf("jpg", "jpeg", "png", "svg", "gif", "tiff", "webp", "xcf")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please do if ( ! extension.lowercase(Locale.ROOT) in arrayOf(...
?
Process exceptional cases first, then go on with the normal flow.
This avoids too may levels of if else.
See https://www.refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correctly blocking RAW.
Can still successfully upload JPG.
Description (required)
Fixes #5537
What changes did you make and why?
Restrict users to only pick Images whose types are allowed by Wikimedia Commons (as mentioned here: https://commons.wikimedia.org/wiki/Commons:File_types)
Tests performed (required)
Tested 4.2.1-debug-main on Xiaomi 11 Lite NE with API level 33
Screenshots (for UI changes only)