mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Added restricted file extensions for uploads
This commit is contained in:
parent
0c9bbb0dfa
commit
bf47978253
@ -90,7 +90,7 @@ namespace Teknik.Areas.API.Controllers
|
|||||||
// Check content type restrictions (Only for encrypting server side
|
// Check content type restrictions (Only for encrypting server side
|
||||||
if (model.encrypt || !string.IsNullOrEmpty(model.key))
|
if (model.encrypt || !string.IsNullOrEmpty(model.key))
|
||||||
{
|
{
|
||||||
if (Config.UploadConfig.RestrictedContentTypes.Contains(model.contentType))
|
if (Config.UploadConfig.RestrictedContentTypes.Contains(model.contentType) || Config.UploadConfig.RestrictedExtensions.Contains(fileExt))
|
||||||
{
|
{
|
||||||
return Json(new { error = new { message = "File Type Not Allowed" } });
|
return Json(new { error = new { message = "File Type Not Allowed" } });
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ namespace Teknik.Areas.Upload.Controllers
|
|||||||
// Check content type restrictions (Only for encrypting server side
|
// Check content type restrictions (Only for encrypting server side
|
||||||
if (encrypt)
|
if (encrypt)
|
||||||
{
|
{
|
||||||
if (Config.UploadConfig.RestrictedContentTypes.Contains(fileType))
|
if (Config.UploadConfig.RestrictedContentTypes.Contains(fileType) || Config.UploadConfig.RestrictedExtensions.Contains(fileExt))
|
||||||
{
|
{
|
||||||
return Json(new { error = new { message = "File Type Not Allowed" } });
|
return Json(new { error = new { message = "File Type Not Allowed" } });
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ namespace Teknik.Configuration
|
|||||||
public int ClamPort { get; set; }
|
public int ClamPort { get; set; }
|
||||||
// Content Type Restrictions
|
// Content Type Restrictions
|
||||||
public List<string> RestrictedContentTypes { get; set; }
|
public List<string> RestrictedContentTypes { get; set; }
|
||||||
|
public List<string> RestrictedExtensions { get; set; }
|
||||||
|
|
||||||
public UploadConfig()
|
public UploadConfig()
|
||||||
{
|
{
|
||||||
@ -61,6 +62,7 @@ namespace Teknik.Configuration
|
|||||||
ClamServer = "localhost";
|
ClamServer = "localhost";
|
||||||
ClamPort = 3310;
|
ClamPort = 3310;
|
||||||
RestrictedContentTypes = new List<string>();
|
RestrictedContentTypes = new List<string>();
|
||||||
|
RestrictedExtensions = new List<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user