From af1615bbb738647d5004364163cc75bfa8e99cb2 Mon Sep 17 00:00:00 2001 From: Ronald Barendse Date: Sun, 6 Oct 2019 11:32:37 +0200 Subject: [PATCH] Removed usage of obsoleted FileSecurityException --- src/Umbraco.Core/IO/PhysicalFileSystem.cs | 2 +- src/Umbraco.Tests/IO/PhysicalFileSystemTests.cs | 2 +- src/Umbraco.Tests/IO/ShadowFileSystemTests.cs | 2 +- .../Repositories/PartialViewRepositoryTests.cs | 7 ++++--- .../Persistence/Repositories/ScriptRepositoryTest.cs | 9 +++++---- .../Persistence/Repositories/StylesheetRepositoryTest.cs | 9 +++++---- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Umbraco.Core/IO/PhysicalFileSystem.cs b/src/Umbraco.Core/IO/PhysicalFileSystem.cs index e4edb2b86b..1cff75a3b2 100644 --- a/src/Umbraco.Core/IO/PhysicalFileSystem.cs +++ b/src/Umbraco.Core/IO/PhysicalFileSystem.cs @@ -314,7 +314,7 @@ namespace Umbraco.Core.IO // nothing prevents us to reach the file, security-wise, yet it is outside // this filesystem's root - throw - throw new FileSecurityException("File '" + opath + "' is outside this filesystem's root."); + throw new UnauthorizedAccessException("File '" + opath + "' is outside this filesystem's root."); } /// diff --git a/src/Umbraco.Tests/IO/PhysicalFileSystemTests.cs b/src/Umbraco.Tests/IO/PhysicalFileSystemTests.cs index ab9b2cf73d..7c3c106724 100644 --- a/src/Umbraco.Tests/IO/PhysicalFileSystemTests.cs +++ b/src/Umbraco.Tests/IO/PhysicalFileSystemTests.cs @@ -101,7 +101,7 @@ namespace Umbraco.Tests.IO Assert.AreEqual(Path.Combine(basePath, @"foo\bar.tmp"), path); // that path is invalid as it would be outside the root directory - Assert.Throws(() => _fileSystem.GetFullPath("../../foo.tmp")); + Assert.Throws(() => _fileSystem.GetFullPath("../../foo.tmp")); // a very long path, which ends up being very long, works path = Repeat("bah/bah/", 50); diff --git a/src/Umbraco.Tests/IO/ShadowFileSystemTests.cs b/src/Umbraco.Tests/IO/ShadowFileSystemTests.cs index 31b00e5cf8..343994b03a 100644 --- a/src/Umbraco.Tests/IO/ShadowFileSystemTests.cs +++ b/src/Umbraco.Tests/IO/ShadowFileSystemTests.cs @@ -238,7 +238,7 @@ namespace Umbraco.Tests.IO var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore"); var ss = new ShadowFileSystem(fs, sfs); - Assert.Throws(() => + Assert.Throws(() => { using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo"))) ss.AddFile("../../f1.txt", ms); diff --git a/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs b/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs index 9c326b3ddc..dad2a0ea17 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/PartialViewRepositoryTests.cs @@ -7,6 +7,7 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Core.Persistence.Repositories.Implement; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing; +using System; namespace Umbraco.Tests.Persistence.Repositories { @@ -77,7 +78,7 @@ namespace Umbraco.Tests.Persistence.Repositories Assert.AreEqual("/Views/Partials/path-2/test-path-3.cshtml", partialView.VirtualPath); partialView = new PartialView(PartialViewType.PartialView, "\\test-path-4.cshtml") { Content = "// partialView" }; - Assert.Throws(() => // fixed in 7.3 - 7.2.8 used to strip the \ + Assert.Throws(() => // fixed in 7.3 - 7.2.8 used to strip the \ { repository.Save(partialView); }); @@ -86,11 +87,11 @@ namespace Umbraco.Tests.Persistence.Repositories Assert.IsNull(partialView); // fixed in 7.3 - 7.2.8 used to... - Assert.Throws(() => + Assert.Throws(() => { partialView = (PartialView) repository.Get("\\test-path-4.cshtml"); // outside the filesystem, does not exist }); - Assert.Throws(() => + Assert.Throws(() => { partialView = (PartialView) repository.Get("../../packages.config"); // outside the filesystem, exists }); diff --git a/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs index 36c1bbdfb4..e3c316cad0 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ScriptRepositoryTest.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using System.Linq; using System.Text; using Moq; @@ -301,7 +302,7 @@ namespace Umbraco.Tests.Persistence.Repositories Assert.AreEqual("/scripts/path-2/test-path-3.js", script.VirtualPath); script = new Script("\\test-path-4.js") { Content = "// script" }; - Assert.Throws(() => // fixed in 7.3 - 7.2.8 used to strip the \ + Assert.Throws(() => // fixed in 7.3 - 7.2.8 used to strip the \ { repository.Save(script); }); @@ -310,11 +311,11 @@ namespace Umbraco.Tests.Persistence.Repositories Assert.IsNull(script); // fixed in 7.3 - 7.2.8 used to... - Assert.Throws(() => + Assert.Throws(() => { script = repository.Get("\\test-path-4.js"); // outside the filesystem, does not exist }); - Assert.Throws(() => + Assert.Throws(() => { script = repository.Get("../packages.config"); // outside the filesystem, exists }); diff --git a/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs index 6fae1d4749..f427f22796 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs @@ -1,4 +1,5 @@ -using System.Data; +using System; +using System.Data; using System.IO; using System.Linq; using System.Text; @@ -284,7 +285,7 @@ namespace Umbraco.Tests.Persistence.Repositories Assert.AreEqual("/css/path-2/test-path-3.css", stylesheet.VirtualPath); stylesheet = new Stylesheet("\\test-path-4.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" }; - Assert.Throws(() => // fixed in 7.3 - 7.2.8 used to strip the \ + Assert.Throws(() => // fixed in 7.3 - 7.2.8 used to strip the \ { repository.Save(stylesheet); }); @@ -294,11 +295,11 @@ namespace Umbraco.Tests.Persistence.Repositories Assert.IsNull(stylesheet); // fixed in 7.3 - 7.2.8 used to... - Assert.Throws(() => + Assert.Throws(() => { stylesheet = repository.Get("\\test-path-4.css"); // outside the filesystem, does not exist }); - Assert.Throws(() => + Assert.Throws(() => { stylesheet = repository.Get("../packages.config"); // outside the filesystem, exists });