Removes umbraco settings: ImageTagAllowedAttributes, UploadAllowDirectories, ensureUniqueNaming, ImageTagAllowedAttributes, ScriptEditorDisable, ScriptFolderPath, UploadAllowDirectories

This commit is contained in:
Shannon
2019-01-30 23:42:25 +11:00
parent a331632800
commit fccfa4f412
27 changed files with 175 additions and 298 deletions

View File

@@ -11,15 +11,9 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
[ConfigurationProperty("imaging")]
internal ContentImagingElement Imaging => (ContentImagingElement) this["imaging"];
[ConfigurationProperty("scripteditor")]
internal ContentScriptEditorElement ScriptEditor => (ContentScriptEditorElement) this["scripteditor"];
[ConfigurationProperty("ResolveUrlsFromTextString")]
internal InnerTextConfigurationElement<bool> ResolveUrlsFromTextString => GetOptionalTextElement("ResolveUrlsFromTextString", false);
[ConfigurationProperty("UploadAllowDirectories")]
internal InnerTextConfigurationElement<bool> UploadAllowDirectories => GetOptionalTextElement("UploadAllowDirectories", true);
public IEnumerable<IContentErrorPage> Error404Collection => Errors.Error404Collection;
[ConfigurationProperty("errors", IsRequired = true)]
@@ -28,9 +22,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
[ConfigurationProperty("notifications", IsRequired = true)]
internal NotificationsElement Notifications => (NotificationsElement) base["notifications"];
[ConfigurationProperty("ensureUniqueNaming")]
internal InnerTextConfigurationElement<bool> EnsureUniqueNaming => GetOptionalTextElement("ensureUniqueNaming", true);
[ConfigurationProperty("XmlCacheEnabled")]
internal InnerTextConfigurationElement<bool> XmlCacheEnabled => GetOptionalTextElement("XmlCacheEnabled", true);
@@ -85,22 +76,10 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
IEnumerable<string> IContentSection.ImageFileTypes => Imaging.ImageFileTypes;
IEnumerable<string> IContentSection.ImageTagAllowedAttributes => Imaging.ImageTagAllowedAttributes;
IEnumerable<IImagingAutoFillUploadField> IContentSection.ImageAutoFillProperties => Imaging.ImageAutoFillProperties;
bool IContentSection.ScriptEditorDisable => ScriptEditor.ScriptEditorDisable;
string IContentSection.ScriptFolderPath => ScriptEditor.ScriptFolderPath;
IEnumerable<string> IContentSection.ScriptFileTypes => ScriptEditor.ScriptFileTypes;
bool IContentSection.ResolveUrlsFromTextString => ResolveUrlsFromTextString;
bool IContentSection.UploadAllowDirectories => UploadAllowDirectories;
bool IContentSection.EnsureUniqueNaming => EnsureUniqueNaming;
bool IContentSection.XmlCacheEnabled => XmlCacheEnabled;
bool IContentSection.ContinouslyUpdateXmlDiskCache => ContinouslyUpdateXmlDiskCache;

View File

@@ -22,18 +22,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
return new[] {"jpeg", "jpg", "gif", "bmp", "png", "tiff", "tif"};
}
[ConfigurationProperty("allowedAttributes")]
internal CommaDelimitedConfigurationElement ImageTagAllowedAttributes
{
get
{
return new OptionalCommaDelimitedConfigurationElement(
(CommaDelimitedConfigurationElement)this["allowedAttributes"],
//set the default
new[] { "src", "alt", "border", "class", "style", "align", "id", "name", "onclick", "usemap" });
}
}
private ImagingAutoFillPropertiesCollection _defaultImageAutoFill;
[ConfigurationCollection(typeof(ImagingAutoFillPropertiesCollection), AddItemName = "uploadField")]

View File

@@ -1,27 +0,0 @@
using System.Collections.Generic;
using System.Configuration;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class ContentScriptEditorElement : UmbracoConfigurationElement
{
[ConfigurationProperty("scriptFolderPath")]
internal InnerTextConfigurationElement<string> ScriptFolderPath
{
get { return GetOptionalTextElement("scriptFolderPath", "/scripts"); }
}
[ConfigurationProperty("scriptFileTypes")]
internal OptionalCommaDelimitedConfigurationElement ScriptFileTypes
{
get { return GetOptionalDelimitedElement("scriptFileTypes", new[] {"js", "xml"}); }
}
[ConfigurationProperty("scriptDisableEditor")]
internal InnerTextConfigurationElement<bool> ScriptEditorDisable
{
get { return GetOptionalTextElement("scriptDisableEditor", false); }
}
}
}

View File

@@ -11,24 +11,12 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
IEnumerable<string> ImageFileTypes { get; }
IEnumerable<string> ImageTagAllowedAttributes { get; }
IEnumerable<IImagingAutoFillUploadField> ImageAutoFillProperties { get; }
string ScriptFolderPath { get; }
IEnumerable<string> ScriptFileTypes { get; }
bool ScriptEditorDisable { get; }
bool ResolveUrlsFromTextString { get; }
bool UploadAllowDirectories { get; }
IEnumerable<IContentErrorPage> Error404Collection { get; }
bool EnsureUniqueNaming { get; }
bool XmlCacheEnabled { get; }
bool ContinouslyUpdateXmlDiskCache { get; }

View File

@@ -185,7 +185,7 @@ namespace Umbraco.Core.IO
/// <param name="filePath">The filepath to validate.</param>
/// <param name="validFileExtensions">The valid extensions.</param>
/// <returns>A value indicating whether the filepath is valid.</returns>
internal static bool VerifyFileExtension(string filePath, List<string> validFileExtensions)
internal static bool VerifyFileExtension(string filePath, IEnumerable<string> validFileExtensions)
{
var ext = Path.GetExtension(filePath);
return ext != null && validFileExtensions.Contains(ext.TrimStart('.'));

View File

@@ -31,7 +31,7 @@ namespace Umbraco.Core.IO.MediaPathSchemes
// prevpath should be "<int>/<filename>" OR "<int>-<filename>"
// and we want to reuse the "<int>" part, so try to find it
var sep = Current.Configs.Settings().Content.UploadAllowDirectories ? "/" : "-";
const string sep = "/";
var pos = previous.IndexOf(sep, StringComparison.Ordinal);
var s = pos > 0 ? previous.Substring(0, pos) : null;
@@ -45,9 +45,7 @@ namespace Umbraco.Core.IO.MediaPathSchemes
if (directory == null)
throw new InvalidOperationException("Cannot use a null directory.");
return Current.Configs.Settings().Content.UploadAllowDirectories
? Path.Combine(directory, filename).Replace('\\', '/')
: directory + "-" + filename;
return Path.Combine(directory, filename).Replace('\\', '/');
}
/// <inheritdoc />

View File

@@ -17,12 +17,13 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
/// </remarks>
internal class DocumentBlueprintRepository : DocumentRepository, IDocumentBlueprintRepository
{
public DocumentBlueprintRepository(IScopeAccessor scopeAccessor, AppCaches appCaches, ILogger logger, IContentTypeRepository contentTypeRepository, ITemplateRepository templateRepository, ITagRepository tagRepository, ILanguageRepository languageRepository, IContentSection settings)
: base(scopeAccessor, appCaches, logger, contentTypeRepository, templateRepository, tagRepository, languageRepository, settings)
public DocumentBlueprintRepository(IScopeAccessor scopeAccessor, AppCaches appCaches, ILogger logger, IContentTypeRepository contentTypeRepository, ITemplateRepository templateRepository, ITagRepository tagRepository, ILanguageRepository languageRepository)
: base(scopeAccessor, appCaches, logger, contentTypeRepository, templateRepository, tagRepository, languageRepository)
{
EnsureUniqueNaming = false; // duplicates are allowed
}
protected override bool EnsureUniqueNaming => false; // duplicates are allowed
protected override Guid NodeObjectTypeId => Constants.ObjectTypes.DocumentBlueprint;
}
}

View File

@@ -30,7 +30,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
private readonly ContentByGuidReadRepository _contentByGuidReadRepository;
private readonly IScopeAccessor _scopeAccessor;
public DocumentRepository(IScopeAccessor scopeAccessor, AppCaches appCaches, ILogger logger, IContentTypeRepository contentTypeRepository, ITemplateRepository templateRepository, ITagRepository tagRepository, ILanguageRepository languageRepository, IContentSection settings)
public DocumentRepository(IScopeAccessor scopeAccessor, AppCaches appCaches, ILogger logger, IContentTypeRepository contentTypeRepository, ITemplateRepository templateRepository, ITagRepository tagRepository, ILanguageRepository languageRepository)
: base(scopeAccessor, appCaches, languageRepository, logger)
{
_contentTypeRepository = contentTypeRepository ?? throw new ArgumentNullException(nameof(contentTypeRepository));
@@ -39,12 +39,14 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
_appCaches = appCaches;
_scopeAccessor = scopeAccessor;
_contentByGuidReadRepository = new ContentByGuidReadRepository(this, scopeAccessor, appCaches, logger);
EnsureUniqueNaming = settings.EnsureUniqueNaming;
}
protected override DocumentRepository This => this;
public bool EnsureUniqueNaming { get; set; }
/// <summary>
/// Default is to always ensure all documents have unique names
/// </summary>
protected virtual bool EnsureUniqueNaming { get; } = true;
// note: is ok to 'new' the repo here as it's a sub-repo really
private PermissionRepository<IContent> PermissionRepository => _permissionRepository

View File

@@ -26,18 +26,16 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
private readonly ITagRepository _tagRepository;
private readonly MediaByGuidReadRepository _mediaByGuidReadRepository;
public MediaRepository(IScopeAccessor scopeAccessor, AppCaches cache, ILogger logger, IMediaTypeRepository mediaTypeRepository, ITagRepository tagRepository, IContentSection contentSection, ILanguageRepository languageRepository)
public MediaRepository(IScopeAccessor scopeAccessor, AppCaches cache, ILogger logger, IMediaTypeRepository mediaTypeRepository, ITagRepository tagRepository, ILanguageRepository languageRepository)
: base(scopeAccessor, cache, languageRepository, logger)
{
_mediaTypeRepository = mediaTypeRepository ?? throw new ArgumentNullException(nameof(mediaTypeRepository));
_tagRepository = tagRepository ?? throw new ArgumentNullException(nameof(tagRepository));
_mediaByGuidReadRepository = new MediaByGuidReadRepository(this, scopeAccessor, cache, logger);
EnsureUniqueNaming = contentSection.EnsureUniqueNaming;
}
protected override MediaRepository This => this;
public bool EnsureUniqueNaming { get; set; }
#region Repository Base
@@ -543,10 +541,6 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
media.ResetDirtyProperties(false);
return media;
}
protected override string EnsureUniqueNodeName(int parentId, string nodeName, int id = 0)
{
return EnsureUniqueNaming == false ? nodeName : base.EnsureUniqueNodeName(parentId, nodeName, id);
}
}
}

View File

@@ -102,7 +102,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
// validate path & extension
var validDir = SystemDirectories.Scripts;
var isValidPath = IOHelper.VerifyEditPath(fullPath, validDir);
var validExts = _contentConfig.ScriptFileTypes.ToList();
var validExts = new[] {"js"};
var isValidExtension = IOHelper.VerifyFileExtension(script.Path, validExts);
return isValidPath && isValidExtension;
}

View File

@@ -249,7 +249,6 @@
<Compile Include="Configuration\UmbracoSettings\ContentErrorPageElement.cs" />
<Compile Include="Configuration\UmbracoSettings\ContentErrorsElement.cs" />
<Compile Include="Configuration\UmbracoSettings\ContentImagingElement.cs" />
<Compile Include="Configuration\UmbracoSettings\ContentScriptEditorElement.cs" />
<Compile Include="Configuration\UmbracoSettings\ContentSectionExtensions.cs" />
<Compile Include="Configuration\UmbracoSettings\DisabledLogTypesCollection.cs" />
<Compile Include="Configuration\UmbracoSettings\ExternalLoggerElement.cs" />