Fixes media uploader issue to ensure non-approved file types are not saved

This commit is contained in:
Shannon
2014-04-16 16:48:52 +10:00
parent 9b344a5a69
commit ad8ab9f46e

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Configuration;
@@ -154,6 +155,14 @@ namespace umbraco.presentation.umbraco.webservices
// get the current file
var uploadFile = context.Request.Files[j];
//Are we allowed to upload this?
var ext = uploadFile.FileName.Substring(uploadFile.FileName.LastIndexOf('.') + 1).ToLower();
if (UmbracoConfig.For.UmbracoSettings().Content.DisallowedUploadFiles.Contains(ext))
{
LogHelper.Warn<MediaUploader>("Cannot upload file " + uploadFile + ", it is not an approved file type");
continue;
}
using (var inputStream = uploadFile.InputStream)
{
// if there was a file uploded