diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs index b78ac1fdfdd0..26cbeb59acee 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs @@ -590,32 +590,41 @@ public ActionResult Upload(List file) var root = _hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.TempFileUploads); var tempPath = Path.Combine(root,fileName); - - using (var stream = System.IO.File.Create(tempPath)) - { - formFile.CopyToAsync(stream).GetAwaiter().GetResult(); - } - - if (ext.InvariantEquals("udt")) + if (Path.GetFullPath(tempPath).StartsWith(Path.GetFullPath(root))) { - model.TempFileName = Path.Combine(root, fileName); + using (var stream = System.IO.File.Create(tempPath)) + { + formFile.CopyToAsync(stream).GetAwaiter().GetResult(); + } - var xd = new XmlDocument + if (ext.InvariantEquals("udt")) { - XmlResolver = null - }; - xd.Load(model.TempFileName); + model.TempFileName = Path.Combine(root, fileName); - model.Alias = xd.DocumentElement?.SelectSingleNode("//DocumentType/Info/Alias")?.FirstChild.Value; - model.Name = xd.DocumentElement?.SelectSingleNode("//DocumentType/Info/Name")?.FirstChild.Value; - } - else + var xd = new XmlDocument + { + XmlResolver = null + }; + xd.Load(model.TempFileName); + + model.Alias = xd.DocumentElement?.SelectSingleNode("//DocumentType/Info/Alias")?.FirstChild.Value; + model.Name = xd.DocumentElement?.SelectSingleNode("//DocumentType/Info/Name")?.FirstChild.Value; + } + else + { + model.Notifications.Add(new BackOfficeNotification( + _localizedTextService.Localize("speechBubbles", "operationFailedHeader"), + _localizedTextService.Localize("media", "disallowedFileType"), + NotificationStyle.Warning)); + } + }else { model.Notifications.Add(new BackOfficeNotification( - _localizedTextService.Localize("speechBubbles","operationFailedHeader"), - _localizedTextService.Localize("media","disallowedFileType"), + _localizedTextService.Localize("speechBubbles", "operationFailedHeader"), + _localizedTextService.Localize("media", "invalidFileName"), NotificationStyle.Warning)); } + } diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml index acd6ccb81727..a3b7d8ab6c85 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml @@ -325,6 +325,7 @@ Click to upload or click here to choose files Cannot upload this file, it does not have an approved file type + Cannot upload this file, it does not have a valid file name Max file size is Media root Failed to create a folder under parent id %0% diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml index 7e7857e602e1..e2a9bf1440ac 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml @@ -329,6 +329,7 @@ Click to upload or click here to choose files Cannot upload this file, it does not have an approved file type + Cannot upload this file, it does not have a valid file name Max file size is Media root Parent and destination folders cannot be the same