revert 431fb76773
This commit is contained in:
parent
86c5e64b20
commit
81394a6f1e
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@ -639,7 +641,7 @@ namespace ASC.Employee.Core.Controllers
|
||||
defaultBr.Read(defaultData, 0, (int)defaultUserPhoto.Length);
|
||||
defaultBr.Close();
|
||||
|
||||
//CheckImgFormat(data);
|
||||
CheckImgFormat(data);
|
||||
|
||||
if (model.Autosave)
|
||||
{
|
||||
@ -726,7 +728,7 @@ namespace ASC.Employee.Core.Controllers
|
||||
br.Read(data, 0, (int)userPhoto.Length);
|
||||
br.Close();
|
||||
|
||||
//CheckImgFormat(data);
|
||||
CheckImgFormat(data);
|
||||
|
||||
if (model.Autosave)
|
||||
{
|
||||
@ -1378,30 +1380,29 @@ namespace ASC.Employee.Core.Controllers
|
||||
UserPhotoManager.SaveOrUpdatePhoto(Tenant, user.ID, imageByteArray);
|
||||
}
|
||||
|
||||
//not working under unix
|
||||
//private static void CheckImgFormat(byte[] data)
|
||||
//{
|
||||
// ImageFormat imgFormat;
|
||||
private static void CheckImgFormat(byte[] data)
|
||||
{
|
||||
ImageFormat imgFormat;
|
||||
|
||||
// try
|
||||
// {
|
||||
// using var stream = new MemoryStream(data);
|
||||
// using var img = new Bitmap(stream);
|
||||
// imgFormat = img.RawFormat;
|
||||
// }
|
||||
// catch (OutOfMemoryException)
|
||||
// {
|
||||
// throw new ImageSizeLimitException();
|
||||
// }
|
||||
// catch (ArgumentException error)
|
||||
// {
|
||||
// throw new UnknownImageFormatException(error);
|
||||
// }
|
||||
try
|
||||
{
|
||||
using var stream = new MemoryStream(data);
|
||||
using var img = new Bitmap(stream);
|
||||
imgFormat = img.RawFormat;
|
||||
}
|
||||
catch (OutOfMemoryException)
|
||||
{
|
||||
throw new ImageSizeLimitException();
|
||||
}
|
||||
catch (ArgumentException error)
|
||||
{
|
||||
throw new UnknownImageFormatException(error);
|
||||
}
|
||||
|
||||
// if (!imgFormat.Equals(ImageFormat.Png) && !imgFormat.Equals(ImageFormat.Jpeg))
|
||||
// {
|
||||
// throw new UnknownImageFormatException();
|
||||
// }
|
||||
//}
|
||||
if (!imgFormat.Equals(ImageFormat.Png) && !imgFormat.Equals(ImageFormat.Jpeg))
|
||||
{
|
||||
throw new UnknownImageFormatException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user