V10: AllowedUploadFiles appsetting not working (#13408)

* Add new Settings

* Use new settings instead of old ones

* Implement AllowedUploadedFiles value to be copied to AllowedUplayedFileExtensions

* Obsolete old settings

* Rename DisallowedUploadFileExtensions

* Implement same fix for DisallowedUploadFiles

* Use new settings for backoffice server variables

* Update the correct setting

Co-authored-by: Zeegaan <nge@umbraco.dk>
This commit is contained in:
Nikolaj Geisle
2022-11-17 09:43:57 +01:00
committed by GitHub
parent 86561d2d2d
commit dff3d8a739
4 changed files with 44 additions and 5 deletions

View File

@@ -119,6 +119,32 @@ public static partial class UmbracoBuilderExtensions
}
});
// TODO: Remove this in V13
// This is to avoid a breaking change in ContentSettings, if the old AllowedFileUploads has a value, and the new
// AllowedFileUploadExtensions does not, copy the value over, if the new has a value, use that instead.
builder.Services.Configure<ContentSettings>(settings =>
{
// We have to use Config.GetSection().Get<string[]>, as the GetSection.GetValue<string[]> simply cannot retrieve a string array
var allowedUploadedFileExtensionsValue = builder.Config.GetSection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.AllowedUploadedFileExtensions)}").Get<string[]>();
var allowedUploadFilesValue = builder.Config.GetSection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.AllowedUploadFiles)}").Get<string[]>();
if (allowedUploadedFileExtensionsValue is null && allowedUploadFilesValue is not null)
{
settings.AllowedUploadedFileExtensions = allowedUploadFilesValue;
}
});
// TODO: Remove this in V13
builder.Services.Configure<ContentSettings>(settings =>
{
var disallowedUploadedFileExtensionsValue = builder.Config.GetSection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.DisallowedUploadedFileExtensions)}").Get<string[]>();
var disallowedUploadFilesValue = builder.Config.GetSection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.DisallowedUploadFiles)}").Get<string[]>();
if (disallowedUploadedFileExtensionsValue is null && disallowedUploadFilesValue is not null)
{
settings.DisallowedUploadedFileExtensions = disallowedUploadFilesValue;
}
});
return builder;
}
}