Removed usage of obsoleted FileSecurityException

This commit is contained in:
Ronald Barendse
2019-10-06 11:32:37 +02:00
parent dc5cdfd3d1
commit af1615bbb7
6 changed files with 17 additions and 14 deletions

View File

@@ -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.");
}
/// <summary>

View File

@@ -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<FileSecurityException>(() => _fileSystem.GetFullPath("../../foo.tmp"));
Assert.Throws<UnauthorizedAccessException>(() => _fileSystem.GetFullPath("../../foo.tmp"));
// a very long path, which ends up being very long, works
path = Repeat("bah/bah/", 50);

View File

@@ -238,7 +238,7 @@ namespace Umbraco.Tests.IO
var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
Assert.Throws<FileSecurityException>(() =>
Assert.Throws<UnauthorizedAccessException>(() =>
{
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo")))
ss.AddFile("../../f1.txt", ms);

View File

@@ -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<FileSecurityException>(() => // fixed in 7.3 - 7.2.8 used to strip the \
Assert.Throws<UnauthorizedAccessException>(() => // 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<FileSecurityException>(() =>
Assert.Throws<UnauthorizedAccessException>(() =>
{
partialView = (PartialView) repository.Get("\\test-path-4.cshtml"); // outside the filesystem, does not exist
});
Assert.Throws<FileSecurityException>(() =>
Assert.Throws<UnauthorizedAccessException>(() =>
{
partialView = (PartialView) repository.Get("../../packages.config"); // outside the filesystem, exists
});

View File

@@ -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<FileSecurityException>(() => // fixed in 7.3 - 7.2.8 used to strip the \
Assert.Throws<UnauthorizedAccessException>(() => // 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<FileSecurityException>(() =>
Assert.Throws<UnauthorizedAccessException>(() =>
{
script = repository.Get("\\test-path-4.js"); // outside the filesystem, does not exist
});
Assert.Throws<FileSecurityException>(() =>
Assert.Throws<UnauthorizedAccessException>(() =>
{
script = repository.Get("../packages.config"); // outside the filesystem, exists
});

View File

@@ -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<FileSecurityException>(() => // fixed in 7.3 - 7.2.8 used to strip the \
Assert.Throws<UnauthorizedAccessException>(() => // 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<FileSecurityException>(() =>
Assert.Throws<UnauthorizedAccessException>(() =>
{
stylesheet = repository.Get("\\test-path-4.css"); // outside the filesystem, does not exist
});
Assert.Throws<FileSecurityException>(() =>
Assert.Throws<UnauthorizedAccessException>(() =>
{
stylesheet = repository.Get("../packages.config"); // outside the filesystem, exists
});