Trim the file name so that it doesn't get accepted by the server if it's a disallowed file

This commit is contained in:
Sebastiaan Janssen
2017-01-04 17:01:26 +01:00
parent c472d4975e
commit 05cb30d79c

View File

@@ -88,35 +88,37 @@ namespace Umbraco.Web.Editors
where TPersisted : IContentBase
{
//Map the property values
foreach (var p in contentItem.ContentDto.Properties)
foreach (var property in contentItem.ContentDto.Properties)
{
//get the dbo property
var dboProperty = contentItem.PersistedContent.Properties[p.Alias];
var dboProperty = contentItem.PersistedContent.Properties[property.Alias];
//create the property data to send to the property editor
var d = new Dictionary<string, object>();
var dictionary = new Dictionary<string, object>();
//add the files if any
var files = contentItem.UploadedFiles.Where(x => x.PropertyAlias == p.Alias).ToArray();
if (files.Length > 0)
{
d.Add("files", files);
}
var files = contentItem.UploadedFiles.Where(x => x.PropertyAlias == property.Alias).ToArray();
foreach (var file in files)
file.FileName = file.FileName.TrimEnd();
if (files.Any())
dictionary.Add("files", files);
var data = new ContentPropertyData(p.Value, p.PreValues, d);
var data = new ContentPropertyData(property.Value, property.PreValues, dictionary);
//get the deserialized value from the property editor
if (p.PropertyEditor == null)
if (property.PropertyEditor == null)
{
LogHelper.Warn<ContentController>("No property editor found for property " + p.Alias);
LogHelper.Warn<ContentController>("No property editor found for property " + property.Alias);
}
else
{
var valueEditor = p.PropertyEditor.ValueEditor;
var valueEditor = property.PropertyEditor.ValueEditor;
//don't persist any bound value if the editor is readonly
if (valueEditor.IsReadOnly == false)
{
var propVal = p.PropertyEditor.ValueEditor.ConvertEditorToDb(data, dboProperty.Value);
var supportTagsAttribute = TagExtractor.GetAttribute(p.PropertyEditor);
var propVal = property.PropertyEditor.ValueEditor.ConvertEditorToDb(data, dboProperty.Value);
var supportTagsAttribute = TagExtractor.GetAttribute(property.PropertyEditor);
if (supportTagsAttribute != null)
{
TagExtractor.SetPropertyTags(dboProperty, data, propVal, supportTagsAttribute);