-
Notifications
You must be signed in to change notification settings - Fork 535
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
Fixes #9667 #9860
Fixes #9667 #9860
Conversation
… verify the file upload type. Signed-off-by: miphilomath <26297035+miphilomath@users.noreply.github.com>
@eviljeff Please review :) |
static/js/zamboni/static_theme.js
Outdated
return file ? file : preLoadBlob; | ||
|
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.
unnecessary extra line.
static/js/zamboni/static_theme.js
Outdated
@@ -11,7 +11,10 @@ $(document).ready(function() { | |||
function getFile() { | |||
file_selector = $wizard.find('#header-img')[0]; | |||
file = file_selector.files[0]; | |||
if (!file.name.match(/.(jpg | jpeg | png | gif | apng)$/i)) | |||
return null; |
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.
Also, you've got some strange indentation :)
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.
Ah! Must be my editor. Let me reformat these lines.
Update: My editor used Tabs that is why the odd indentation.
static/js/zamboni/static_theme.js
Outdated
@@ -11,7 +11,10 @@ $(document).ready(function() { | |||
function getFile() { | |||
file_selector = $wizard.find('#header-img')[0]; | |||
file = file_selector.files[0]; | |||
if (!file.name.match(/.(jpg | jpeg | png | gif | apng)$/i)) |
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.
This works great (apart from missing .svg
off) but it'd be good to re-use the accept
attribute from the html so the list of acceptable files is only defined in one place.
How about:
if (file && $wizard.find('#header-img').attr('accept').split(',').indexOf(file.type)== -1)
?
It uses file.type to get content type which should hopefully be more robust too.
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.
Wow! That looks like a more clean and efficient way of doing the task.
Thanks :)
Signed-off-by: miphilomath <26297035+miphilomath@users.noreply.github.com>
r+ thanks for the contribution |
Thanks, @miphilomath, and welcome onboard! 🎉Your contribution has been added to our recognition wiki. I look forward to seeing you around the project! |
Thanks @caitmuenster @eviljeff! I wanted to meet you guys at MozFest but couldn't due to my volunteering duties, May be next time :) |
Changed the file type separator with comma(,) and added a function to verify the file upload type.
Signed-off-by: miphilomath 26297035+miphilomath@users.noreply.github.com
PRs open for the same issue.
Fixes #ISSUENUM
at the top of your PR.