-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[avatar] add error handlers for avatar setup #17805
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
Conversation
|
@oparoz I got following for this huge image: Can we somehow limit the avatar stuff to not accept images that are bigger than 10 MB or so? |
|
nice 👍 |
settings/js/personal.js
Outdated
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.
No string concatenation for translations please.
French uses : (space before and after colon)
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.
I just move the colon inside, because on most other translations with a trailing whitespace it was added to the translation as well. And thanks for the hint.
|
@MorrisJobke - I'm not familiar with the avatar code, but it should be possible to check the size of the image in the controller and send back an error if it's deemed too large. I think a hard limit makes sense as it's only an avatar and lots of systems place limits on dimensions or size. |
|
@MorrisJobke - I think a code 413 would be appropriate and the JS could alter the error message based on the code it receives. |
Can you make this a separate PR? That would be really nice :) |
settings/js/personal.js
Outdated
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 use place holders for the status and statusText? I mean that's why we have them ;)
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.
I always forgot about them 🙈
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.
I changed it.
|
Jenkins: #17809 |
|
@nickvergessen @oparoz Please review :) |
Well we do pose limits on the avatar size. But only if a user requests the avatar. max 2048x2048. |
So the avatar controller can't do this. Because the file needs to be uploaded before we can make this happen. A solution is to use HTML5 (if we can): see https://jsfiddle.net/xnkhN/ But lets not complicate this more than it has to. This PR shows a nice error message if things go bad. If users decide it is a good idea to upload a 100MB file to create a tiny avatar I do not think it is then our responsibility to make their experience as smooth as possible. I do wish we had javascript tests for those files. |
Yes, but uploading the file is only a problem if you encrypt it right away. If it's in /tmp, then you can get its size before processing it further.
I agree, but what about the case were a user wants to use one of the pictures which are already in his cloud? |
|
@oparoz nope then it is not all good. We allow the user to crop an image to create an avatar. So we should allow images larger than 2048x2048. |
|
@MorrisJobke for me there is no error on server side - but the image is not shown after upload I guess some max file size check is reasonable. |
OK, then users will be able to break PHP if their memory limit is set too low, just like for previews, except that it's more annoying when you don't get the avatar picture. |
|
To me it would make sense to have a max limit here of 20MB for now - talking about a solution which can be backported as well. In the long run the avatar code needs to get rid of that cache class - it is not designed to operate with that big data |
|
@MorrisJobke @oparoz size limit is in place |
We need the same things for the dimensions (a 4MB JPEG can break PHP if set with a 64MB memory limit), but I think it might be best to keep it in the Preview class |
settings/js/personal.js
Outdated
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.
Currently it displays: 400 Bad request. Which does not tell the user anything. It should display the returned message: File is too big
|
@rullzer @Xenopathic @LukasReschke @oparoz Please review :) |
settings/js/personal.js
Outdated
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.
Huh?! Copy-paste fail ?
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.
😫
b5ff7c2 to
4c54086
Compare
4c54086 to
356ed4c
Compare
|
settings/js/personal.js
Outdated
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.
data is undefined in this function.
Bad copy paste?
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.
👾 😢 me an js 💣
356ed4c to
ca173be
Compare
|
Looking good now! 👍 |
|
On tiny last thing. It now shows:
Shouldn't that be something like
Or even without the code? Since the user does not care about the response code. |
|
@owncloud-bot retest this please |
@rullzer branch hijack permission granted - THX |
|
Jenkins is happy: #17968 (comment) |
ca173be to
73f025a
Compare
|
@rullzer simply:
No error code indeed. ;) |
Already done - 73f025a#diff-a1c52fafc7d1f682c8849c5c62297682R244 status code is only displayed if there is no message communicated to the client |
Ah I'm to late ;) Looks simple enough to backport! |
settings/js/personal.js
Outdated
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.
That looks weird. Two times status text?
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.
Okay - I better stop writing JS
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.
I will fix it
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.
Fixed
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.
o, mmm missed that.
this is why we need javascript tests for those classes as well!
Good catch @MorrisJobke
add colon to translated string use placeholder in t() Adding a size limitation for avatar upload Unit test for file size Fix typo & display server side error message
73f025a to
e184157
Compare
|
A new inspection was created. |
|
Now I'm fine with this 👍 |
|
@owncloud-bot retest this please |
[avatar] add error handlers for avatar setup


Steps to reproduce:
cc @DeepDiver1975 @CaptionF @kawohl @Henni @rullzer @Xenopathic @LukasReschke @oparoz