Log Message
Better handling of unsupported image formats.
Modified Paths
Diff
Modified: trunk/hudson/plugins/avatar/src/main/java/net/hurstfrost/jenkins/avatar/user/AvatarProperty.java (40938 => 40939)
--- trunk/hudson/plugins/avatar/src/main/java/net/hurstfrost/jenkins/avatar/user/AvatarProperty.java 2013-06-23 08:40:00 UTC (rev 40938)
+++ trunk/hudson/plugins/avatar/src/main/java/net/hurstfrost/jenkins/avatar/user/AvatarProperty.java 2013-06-24 15:22:26 UTC (rev 40939)
@@ -135,23 +135,23 @@
*/
public void doUpload(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
FileItem file = req.getFileItem("avatarimage.file");
+ AvatarImage currentReplacementImage = replacementImage;
if (file != null && !file.getName().isEmpty()) {
if (file.getSize() > MAX_AVATAR_IMAGE_SIZE) {
lastError = "Uploaded image is too large.";
} else {
- // Ensure we can interpret this file as an Image
- try {
- replacementImage = AvatarImage.fromBytes(file.get());
- } catch (Exception e) {
- // Uploaded file is invalid, ignore
- lastError = e.getMessage();
+ replacementImage = AvatarImage.fromBytes(file.get());
+
+ if (replacementImage == null) {
+ lastError = "Unsupported image format " + file.getName();
+ replacementImage = currentReplacementImage;
}
}
} else {
// Indicate that image should be removed
lastWarning = "Empty image uploaded. Avatar will be removed on save.";
- replacementImage = new AvatarImage();
+ replacementImage = new AvatarImage();
}
req.getView(this, "configIframe").forward(req, rsp);
You received this message because you are subscribed to the Google Groups "Jenkins Commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
