AB4227 - Removed StringExtensions from core..
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Umbraco.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Strings;
|
||||
|
||||
@@ -1396,5 +1397,54 @@ namespace Umbraco.Core
|
||||
{
|
||||
return shortStringHelper.CleanString(text, stringType, separator, culture);
|
||||
}
|
||||
|
||||
// note: LegacyCurrent.ShortStringHelper will produce 100% backward-compatible output for SplitPascalCasing.
|
||||
// other helpers may not. DefaultCurrent.ShortStringHelper produces better, but non-compatible, results.
|
||||
|
||||
/// <summary>
|
||||
/// Splits a Pascal cased string into a phrase separated by spaces.
|
||||
/// </summary>
|
||||
/// <param name="phrase">The text to split.</param>
|
||||
/// <param name="shortStringHelper"></param>
|
||||
/// <returns>The split text.</returns>
|
||||
public static string SplitPascalCasing(this string phrase, IShortStringHelper shortStringHelper)
|
||||
{
|
||||
return shortStringHelper.SplitPascalCasing(phrase, ' ');
|
||||
}
|
||||
|
||||
//NOTE: Not sure what this actually does but is used a few places, need to figure it out and then move to StringExtensions and obsolete.
|
||||
// it basically is yet another version of SplitPascalCasing
|
||||
// plugging string extensions here to be 99% compatible
|
||||
// the only diff. is with numbers, Number6Is was "Number6 Is", and the new string helper does it too,
|
||||
// but the legacy one does "Number6Is"... assuming it is not a big deal.
|
||||
internal static string SpaceCamelCasing(this string phrase, IShortStringHelper shortStringHelper)
|
||||
{
|
||||
return phrase.Length < 2 ? phrase : phrase.SplitPascalCasing(shortStringHelper).ToFirstUpperInvariant();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans a string, in the context of the invariant culture, to produce a string that can safely be used as a filename,
|
||||
/// both internally (on disk) and externally (as a url).
|
||||
/// </summary>
|
||||
/// <param name="text">The text to filter.</param>
|
||||
/// <param name="shortStringHelper"></param>
|
||||
/// <returns>The safe filename.</returns>
|
||||
public static string ToSafeFileName(this string text, IShortStringHelper shortStringHelper)
|
||||
{
|
||||
return shortStringHelper.CleanStringForSafeFileName(text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans a string, in the context of the invariant culture, to produce a string that can safely be used as a filename,
|
||||
/// both internally (on disk) and externally (as a url).
|
||||
/// </summary>
|
||||
/// <param name="text">The text to filter.</param>
|
||||
/// <param name="shortStringHelper"></param>
|
||||
/// <param name="culture">The culture.</param>
|
||||
/// <returns>The safe filename.</returns>
|
||||
public static string ToSafeFileName(this string text, IShortStringHelper shortStringHelper, string culture)
|
||||
{
|
||||
return shortStringHelper.CleanStringForSafeFileName(text, culture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace Umbraco.Core.Configuration
|
||||
}
|
||||
|
||||
public IHostingSettings HostingSettings { get; } = new HostingSettings();
|
||||
public ICoreDebug CoreDebug { get; } = new CoreDebug();
|
||||
|
||||
public IUmbracoSettingsSection UmbracoSettings { get; }
|
||||
|
||||
public Configs Create(IIOHelper ioHelper)
|
||||
@@ -26,7 +28,7 @@ namespace Umbraco.Core.Configuration
|
||||
|
||||
configs.Add<IUserPasswordConfiguration>(() => new DefaultPasswordConfig());
|
||||
configs.Add<IMemberPasswordConfiguration>(() => new DefaultPasswordConfig());
|
||||
configs.Add<ICoreDebug>(() => new CoreDebug());
|
||||
configs.Add<ICoreDebug>(() => CoreDebug);
|
||||
configs.Add<IConnectionStrings>(() => new ConnectionStrings());
|
||||
configs.AddCoreConfigs(ioHelper);
|
||||
return configs;
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Strings;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
|
||||
///<summary>
|
||||
/// String extension methods
|
||||
///</summary>
|
||||
public static class StringExtensions
|
||||
{
|
||||
|
||||
// FORMAT STRINGS
|
||||
|
||||
/// <summary>
|
||||
/// Cleans a string to produce a string that can safely be used in an alias.
|
||||
/// </summary>
|
||||
/// <param name="alias">The text to filter.</param>
|
||||
/// <returns>The safe alias.</returns>
|
||||
public static string ToSafeAlias(this string alias)
|
||||
{
|
||||
return Current.ShortStringHelper.CleanStringForSafeAlias(alias);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans a string to produce a string that can safely be used in an alias.
|
||||
/// </summary>
|
||||
/// <param name="alias">The text to filter.</param>
|
||||
/// <param name="camel">A value indicating that we want to camel-case the alias.</param>
|
||||
/// <returns>The safe alias.</returns>
|
||||
public static string ToSafeAlias(this string alias, bool camel)
|
||||
{
|
||||
var a = Current.ShortStringHelper.CleanStringForSafeAlias(alias);
|
||||
if (string.IsNullOrWhiteSpace(a) || camel == false) return a;
|
||||
return char.ToLowerInvariant(a[0]) + a.Substring(1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans a string, in the context of a specified culture, to produce a string that can safely be used in an alias.
|
||||
/// </summary>
|
||||
/// <param name="alias">The text to filter.</param>
|
||||
/// <param name="culture">The culture.</param>
|
||||
/// <returns>The safe alias.</returns>
|
||||
public static string ToSafeAlias(this string alias, string culture)
|
||||
{
|
||||
return Current.ShortStringHelper.CleanStringForSafeAlias(alias, culture);
|
||||
}
|
||||
|
||||
// the new methods to get a url segment
|
||||
|
||||
/// <summary>
|
||||
/// Cleans a string to produce a string that can safely be used in an url segment.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to filter.</param>
|
||||
/// <returns>The safe url segment.</returns>
|
||||
public static string ToUrlSegment(this string text)
|
||||
{
|
||||
if (text == null) throw new ArgumentNullException(nameof(text));
|
||||
if (string.IsNullOrWhiteSpace(text)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(text));
|
||||
|
||||
return Current.ShortStringHelper.CleanStringForUrlSegment(text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans a string, in the context of a specified culture, to produce a string that can safely be used in an url segment.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to filter.</param>
|
||||
/// <param name="culture">The culture.</param>
|
||||
/// <returns>The safe url segment.</returns>
|
||||
public static string ToUrlSegment(this string text, string culture)
|
||||
{
|
||||
if (text == null) throw new ArgumentNullException(nameof(text));
|
||||
if (string.IsNullOrWhiteSpace(text)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(text));
|
||||
|
||||
return Current.ShortStringHelper.CleanStringForUrlSegment(text, culture);
|
||||
}
|
||||
|
||||
// the new methods to clean a string (to alias, url segment...)
|
||||
|
||||
/// <summary>
|
||||
/// Cleans a string.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to clean.</param>
|
||||
/// <param name="stringType">A flag indicating the target casing and encoding of the string. By default,
|
||||
/// strings are cleaned up to camelCase and Ascii.</param>
|
||||
/// <returns>The clean string.</returns>
|
||||
/// <remarks>The string is cleaned in the context of the ICurrent.ShortStringHelper default culture.</remarks>
|
||||
public static string ToCleanString(this string text, CleanStringType stringType)
|
||||
{
|
||||
return Current.ShortStringHelper.CleanString(text, stringType);
|
||||
}
|
||||
|
||||
// note: LegacyCurrent.ShortStringHelper will produce 100% backward-compatible output for SplitPascalCasing.
|
||||
// other helpers may not. DefaultCurrent.ShortStringHelper produces better, but non-compatible, results.
|
||||
|
||||
/// <summary>
|
||||
/// Splits a Pascal cased string into a phrase separated by spaces.
|
||||
/// </summary>
|
||||
/// <param name="phrase">The text to split.</param>
|
||||
/// <returns>The split text.</returns>
|
||||
public static string SplitPascalCasing(this string phrase)
|
||||
{
|
||||
return Current.ShortStringHelper.SplitPascalCasing(phrase, ' ');
|
||||
}
|
||||
|
||||
//NOTE: Not sure what this actually does but is used a few places, need to figure it out and then move to StringExtensions and obsolete.
|
||||
// it basically is yet another version of SplitPascalCasing
|
||||
// plugging string extensions here to be 99% compatible
|
||||
// the only diff. is with numbers, Number6Is was "Number6 Is", and the new string helper does it too,
|
||||
// but the legacy one does "Number6Is"... assuming it is not a big deal.
|
||||
internal static string SpaceCamelCasing(this string phrase)
|
||||
{
|
||||
return phrase.Length < 2 ? phrase : phrase.SplitPascalCasing().ToFirstUpperInvariant();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans a string, in the context of the invariant culture, to produce a string that can safely be used as a filename,
|
||||
/// both internally (on disk) and externally (as a url).
|
||||
/// </summary>
|
||||
/// <param name="text">The text to filter.</param>
|
||||
/// <returns>The safe filename.</returns>
|
||||
public static string ToSafeFileName(this string text)
|
||||
{
|
||||
return Current.ShortStringHelper.CleanStringForSafeFileName(text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans a string, in the context of the invariant culture, to produce a string that can safely be used as a filename,
|
||||
/// both internally (on disk) and externally (as a url).
|
||||
/// </summary>
|
||||
/// <param name="text">The text to filter.</param>
|
||||
/// <param name="culture">The culture.</param>
|
||||
/// <returns>The safe filename.</returns>
|
||||
public static string ToSafeFileName(this string text, string culture)
|
||||
{
|
||||
return Current.ShortStringHelper.CleanStringForSafeFileName(text, culture);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,14 @@ namespace Umbraco.Core
|
||||
/// Tries to return a value based on a property name for an object but ignores case sensitivity
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="shortStringHelper"></param>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="memberName"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// Currently this will only work for ProperCase and camelCase properties, see the TODO below to enable complete case insensitivity
|
||||
/// </remarks>
|
||||
internal static Attempt<object> GetMemberIgnoreCase(this Type type, object target, string memberName)
|
||||
internal static Attempt<object> GetMemberIgnoreCase(this Type type, IShortStringHelper shortStringHelper, object target, string memberName)
|
||||
{
|
||||
Func<string, Attempt<object>> getMember =
|
||||
memberAlias =>
|
||||
@@ -49,8 +50,8 @@ namespace Umbraco.Core
|
||||
{
|
||||
//if we cannot get with the current alias, try changing it's case
|
||||
attempt = memberName[0].IsUpperCase()
|
||||
? getMember(memberName.ToCleanString(CleanStringType.Ascii | CleanStringType.ConvertCase | CleanStringType.CamelCase))
|
||||
: getMember(memberName.ToCleanString(CleanStringType.Ascii | CleanStringType.ConvertCase | CleanStringType.PascalCase));
|
||||
? getMember(memberName.ToCleanString(shortStringHelper, CleanStringType.Ascii | CleanStringType.ConvertCase | CleanStringType.CamelCase))
|
||||
: getMember(memberName.ToCleanString(shortStringHelper, CleanStringType.Ascii | CleanStringType.ConvertCase | CleanStringType.PascalCase));
|
||||
|
||||
// TODO: If this still fails then we should get a list of properties from the object and then compare - doing the above without listing
|
||||
// all properties will surely be faster than using reflection to get ALL properties first and then query against them.
|
||||
@@ -58,6 +59,6 @@ namespace Umbraco.Core
|
||||
|
||||
return attempt;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,9 +144,7 @@
|
||||
<Compile Include="Security\ConfiguredPasswordValidator.cs" />
|
||||
<Compile Include="Security\PasswordSecurity.cs" />
|
||||
<Compile Include="Security\UmbracoBackOfficeIdentity.cs" />
|
||||
<Compile Include="StringExtensions.cs" />
|
||||
<Compile Include="TypeLoaderExtensions.cs" />
|
||||
<Compile Include="RuntimeOptions.cs" />
|
||||
<Compile Include="FileResources\Files.Designer.cs" />
|
||||
<Compile Include="MainDom.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
@@ -8,6 +8,7 @@ using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.ModelsBuilder.Embedded.BackOffice;
|
||||
using Umbraco.ModelsBuilder.Embedded.Configuration;
|
||||
using Umbraco.Web;
|
||||
@@ -21,12 +22,14 @@ namespace Umbraco.ModelsBuilder.Embedded.Compose
|
||||
{
|
||||
|
||||
private readonly IModelsBuilderConfig _config;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
private readonly LiveModelsProvider _liveModelsProvider;
|
||||
private readonly OutOfDateModelsStatus _outOfDateModels;
|
||||
|
||||
public ModelsBuilderComponent(IModelsBuilderConfig config, LiveModelsProvider liveModelsProvider, OutOfDateModelsStatus outOfDateModels)
|
||||
public ModelsBuilderComponent(IModelsBuilderConfig config, IShortStringHelper shortStringHelper, LiveModelsProvider liveModelsProvider, OutOfDateModelsStatus outOfDateModels)
|
||||
{
|
||||
_config = config;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
_liveModelsProvider = liveModelsProvider;
|
||||
_outOfDateModels = outOfDateModels;
|
||||
}
|
||||
@@ -116,7 +119,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Compose
|
||||
// + this is how we get the default model name in Umbraco.ModelsBuilder.Umbraco.Application
|
||||
var alias = e.AdditionalData["ContentTypeAlias"].ToString();
|
||||
var name = template.Name; // will be the name of the content type since we are creating
|
||||
var className = UmbracoServices.GetClrName(name, alias);
|
||||
var className = UmbracoServices.GetClrName(_shortStringHelper, name, alias);
|
||||
|
||||
var modelNamespace = _config.ModelsNamespace;
|
||||
|
||||
|
||||
@@ -17,13 +17,20 @@ namespace Umbraco.ModelsBuilder.Embedded
|
||||
private readonly IMediaTypeService _mediaTypeService;
|
||||
private readonly IMemberTypeService _memberTypeService;
|
||||
private readonly IPublishedContentTypeFactory _publishedContentTypeFactory;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
|
||||
public UmbracoServices(IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, IPublishedContentTypeFactory publishedContentTypeFactory)
|
||||
public UmbracoServices(
|
||||
IContentTypeService contentTypeService,
|
||||
IMediaTypeService mediaTypeService,
|
||||
IMemberTypeService memberTypeService,
|
||||
IPublishedContentTypeFactory publishedContentTypeFactory,
|
||||
IShortStringHelper shortStringHelper)
|
||||
{
|
||||
_contentTypeService = contentTypeService;
|
||||
_mediaTypeService = mediaTypeService;
|
||||
_memberTypeService = memberTypeService;
|
||||
_publishedContentTypeFactory = publishedContentTypeFactory;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
}
|
||||
|
||||
#region Services
|
||||
@@ -61,10 +68,10 @@ namespace Umbraco.ModelsBuilder.Embedded
|
||||
return GetTypes(PublishedItemType.Member, memberTypes); // aliases have to be unique here
|
||||
}
|
||||
|
||||
public static string GetClrName(string name, string alias)
|
||||
public static string GetClrName(IShortStringHelper shortStringHelper, string name, string alias)
|
||||
{
|
||||
// ModelsBuilder's legacy - but not ideal
|
||||
return alias.ToCleanString(CleanStringType.ConvertCase | CleanStringType.PascalCase);
|
||||
return alias.ToCleanString(shortStringHelper, CleanStringType.ConvertCase | CleanStringType.PascalCase);
|
||||
}
|
||||
|
||||
private IList<TypeModel> GetTypes(PublishedItemType itemType, IContentTypeComposition[] contentTypes)
|
||||
@@ -79,7 +86,7 @@ namespace Umbraco.ModelsBuilder.Embedded
|
||||
{
|
||||
Id = contentType.Id,
|
||||
Alias = contentType.Alias,
|
||||
ClrName = GetClrName(contentType.Name, contentType.Alias),
|
||||
ClrName = GetClrName(_shortStringHelper, contentType.Name, contentType.Alias),
|
||||
ParentId = contentType.ParentId,
|
||||
|
||||
Name = contentType.Name,
|
||||
@@ -121,7 +128,7 @@ namespace Umbraco.ModelsBuilder.Embedded
|
||||
var propertyModel = new PropertyModel
|
||||
{
|
||||
Alias = propertyType.Alias,
|
||||
ClrName = GetClrName(propertyType.Name, propertyType.Alias),
|
||||
ClrName = GetClrName(_shortStringHelper, propertyType.Name, propertyType.Alias),
|
||||
|
||||
Name = propertyType.Name,
|
||||
Description = propertyType.Description
|
||||
|
||||
@@ -12,6 +12,7 @@ using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
using Umbraco.Core.Scoping;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Cache;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
@@ -54,6 +55,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
ILogger logger,
|
||||
IGlobalSettings globalSettings,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IShortStringHelper shortStringHelper,
|
||||
ISiteDomainHelper siteDomainHelper,
|
||||
IEntityXmlSerializer entitySerializer,
|
||||
MainDom mainDom,
|
||||
@@ -62,7 +64,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
publishedSnapshotAccessor, variationContextAccessor, umbracoContextAccessor,
|
||||
documentRepository, mediaRepository, memberRepository,
|
||||
defaultCultureAccessor,
|
||||
logger, globalSettings, hostingEnvironment, siteDomainHelper, entitySerializer, null, mainDom, testing, enableRepositoryEvents)
|
||||
logger, globalSettings, hostingEnvironment, shortStringHelper, siteDomainHelper, entitySerializer, null, mainDom, testing, enableRepositoryEvents)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
}
|
||||
@@ -79,6 +81,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
ILogger logger,
|
||||
IGlobalSettings globalSettings,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IShortStringHelper shortStringHelper,
|
||||
ISiteDomainHelper siteDomainHelper,
|
||||
IEntityXmlSerializer entitySerializer,
|
||||
PublishedContentTypeCache contentTypeCache,
|
||||
@@ -93,7 +96,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
|
||||
_xmlStore = new XmlStore(serviceContext.ContentTypeService, serviceContext.ContentService, scopeProvider, _routesCache,
|
||||
_contentTypeCache, publishedSnapshotAccessor, mainDom, testing, enableRepositoryEvents,
|
||||
documentRepository, mediaRepository, memberRepository, globalSettings, entitySerializer, hostingEnvironment);
|
||||
documentRepository, mediaRepository, memberRepository, globalSettings, entitySerializer, hostingEnvironment, shortStringHelper);
|
||||
|
||||
_domainService = serviceContext.DomainService;
|
||||
_memberService = serviceContext.MemberService;
|
||||
|
||||
@@ -19,6 +19,7 @@ using Umbraco.Core.Scoping;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Changes;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.Xml;
|
||||
using Umbraco.Web.Cache;
|
||||
using Umbraco.Web.Composing;
|
||||
@@ -45,6 +46,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly IEntityXmlSerializer _entitySerializer;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
private XmlStoreFilePersister _persisterTask;
|
||||
private volatile bool _released;
|
||||
private bool _withRepositoryEvents;
|
||||
@@ -63,8 +65,8 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
/// </summary>
|
||||
/// <remarks>The default constructor will boot the cache, load data from file or database, /// wire events in order to manage changes, etc.</remarks>
|
||||
public XmlStore(IContentTypeService contentTypeService, IContentService contentService, IScopeProvider scopeProvider, RoutesCache routesCache, PublishedContentTypeCache contentTypeCache,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, MainDom mainDom, IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository, IGlobalSettings globalSettings, IEntityXmlSerializer entitySerializer, IHostingEnvironment hostingEnvironment)
|
||||
: this(contentTypeService, contentService, scopeProvider, routesCache, contentTypeCache, publishedSnapshotAccessor, mainDom, false, false, documentRepository, mediaRepository, memberRepository, globalSettings, entitySerializer, hostingEnvironment)
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, MainDom mainDom, IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository, IGlobalSettings globalSettings, IEntityXmlSerializer entitySerializer, IHostingEnvironment hostingEnvironment, IShortStringHelper shortStringHelper)
|
||||
: this(contentTypeService, contentService, scopeProvider, routesCache, contentTypeCache, publishedSnapshotAccessor, mainDom, false, false, documentRepository, mediaRepository, memberRepository, globalSettings, entitySerializer, hostingEnvironment, shortStringHelper)
|
||||
{ }
|
||||
|
||||
// internal for unit tests
|
||||
@@ -72,7 +74,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
// TODO: er, we DO have a DB?
|
||||
internal XmlStore(IContentTypeService contentTypeService, IContentService contentService, IScopeProvider scopeProvider, RoutesCache routesCache, PublishedContentTypeCache contentTypeCache,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, MainDom mainDom,
|
||||
bool testing, bool enableRepositoryEvents, IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository, IGlobalSettings globalSettings, IEntityXmlSerializer entitySerializer, IHostingEnvironment hostingEnvironment)
|
||||
bool testing, bool enableRepositoryEvents, IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository, IGlobalSettings globalSettings, IEntityXmlSerializer entitySerializer, IHostingEnvironment hostingEnvironment, IShortStringHelper shortStringHelper)
|
||||
{
|
||||
if (testing == false)
|
||||
EnsureConfigurationIsValid();
|
||||
@@ -89,6 +91,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
_globalSettings = globalSettings;
|
||||
_entitySerializer = entitySerializer;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
|
||||
_xmlFileName = Current.IOHelper.MapPath(SystemFiles.GetContentCacheXml(_hostingEnvironment));
|
||||
|
||||
@@ -405,7 +408,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
var dtdInner = new StringBuilder();
|
||||
var contentTypes = _contentTypeService.GetAll();
|
||||
// though aliases should be safe and non null already?
|
||||
var aliases = contentTypes.Select(x => x.Alias.ToSafeAlias()).WhereNotNull();
|
||||
var aliases = contentTypes.Select(x => x.Alias.ToSafeAlias(_shortStringHelper)).WhereNotNull();
|
||||
foreach (var alias in aliases)
|
||||
{
|
||||
dtdInner.AppendLine($"<!ELEMENT {alias} ANY>");
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Umbraco.Tests.Models
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Root Home", -1);
|
||||
ServiceContext.ContentService.Save(content, Constants.Security.SuperUserId);
|
||||
|
||||
var nodeName = content.ContentType.Alias.ToSafeAlias();
|
||||
var nodeName = content.ContentType.Alias.ToSafeAlias(ShortStringHelper);
|
||||
var urlName = content.GetUrlSegment(ShortStringHelper, new[]{new DefaultUrlSegmentProvider(ShortStringHelper) });
|
||||
|
||||
// Act
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Umbraco.Tests.Models
|
||||
media.SetValue(Constants.Conventions.Media.Bytes, "100");
|
||||
media.SetValue(Constants.Conventions.Media.Extension, "png");
|
||||
|
||||
var nodeName = media.ContentType.Alias.ToSafeAlias();
|
||||
var nodeName = media.ContentType.Alias.ToSafeAlias(ShortStringHelper);
|
||||
var urlName = media.GetUrlSegment(ShortStringHelper, new[] { new DefaultUrlSegmentProvider(ShortStringHelper) });
|
||||
|
||||
// Act
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace Umbraco.Tests.Routing
|
||||
WebInitialComponent.CreateRoutes(
|
||||
new TestUmbracoContextAccessor(),
|
||||
TestObjects.GetGlobalSettings(),
|
||||
ShortStringHelper,
|
||||
new SurfaceControllerTypeCollection(Enumerable.Empty<Type>()),
|
||||
new UmbracoApiControllerTypeCollection(Enumerable.Empty<Type>()));
|
||||
}
|
||||
@@ -106,7 +107,7 @@ namespace Umbraco.Tests.Routing
|
||||
frequest.TemplateModel = template;
|
||||
|
||||
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
|
||||
var handler = new RenderRouteHandler(umbracoContext, new TestControllerFactory(umbracoContextAccessor, Mock.Of<ILogger>()));
|
||||
var handler = new RenderRouteHandler(umbracoContext, new TestControllerFactory(umbracoContextAccessor, Mock.Of<ILogger>()), ShortStringHelper);
|
||||
|
||||
handler.GetHandlerForRoute(umbracoContext.HttpContext.Request.RequestContext, frequest);
|
||||
Assert.AreEqual("RenderMvc", routeData.Values["controller"].ToString());
|
||||
@@ -155,13 +156,13 @@ namespace Umbraco.Tests.Routing
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
new UmbracoHelper(Mock.Of<IPublishedContent>(), Mock.Of<ITagQuery>(), Mock.Of<ICultureDictionaryFactory>(), Mock.Of<IUmbracoComponentRenderer>(), Mock.Of<IPublishedContentQuery>(), membershipHelper));
|
||||
}));
|
||||
}), ShortStringHelper);
|
||||
|
||||
handler.GetHandlerForRoute(umbracoContext.HttpContext.Request.RequestContext, frequest);
|
||||
Assert.AreEqual("CustomDocument", routeData.Values["controller"].ToString());
|
||||
Assert.AreEqual(
|
||||
//global::umbraco.cms.helpers.Casing.SafeAlias(template.Alias),
|
||||
template.Alias.ToSafeAlias(),
|
||||
template.Alias.ToSafeAlias(ShortStringHelper),
|
||||
routeData.Values["action"].ToString());
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Umbraco.Tests.Strings
|
||||
[TestCase("WhoIsNumber6InTheVillage", "Who Is Number6 In The Village")] // now fixed since DefaultShortStringHelper is the default
|
||||
public void SpaceCamelCasing(string input, string expected)
|
||||
{
|
||||
var output = input.SpaceCamelCasing();
|
||||
var output = input.SpaceCamelCasing(ShortStringHelper);
|
||||
Assert.AreEqual(expected, output);
|
||||
}
|
||||
|
||||
|
||||
@@ -228,77 +228,77 @@ namespace Umbraco.Tests.Strings
|
||||
[Test]
|
||||
public void ToUrlAlias()
|
||||
{
|
||||
var output = "JUST-ANYTHING".ToUrlSegment();
|
||||
var output = "JUST-ANYTHING".ToUrlSegment(ShortStringHelper);
|
||||
Assert.AreEqual("URL-SEGMENT::JUST-ANYTHING", output);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FormatUrl()
|
||||
{
|
||||
var output = "JUST-ANYTHING".ToUrlSegment();
|
||||
var output = "JUST-ANYTHING".ToUrlSegment(ShortStringHelper);
|
||||
Assert.AreEqual("URL-SEGMENT::JUST-ANYTHING", output);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToUmbracoAlias()
|
||||
{
|
||||
var output = "JUST-ANYTHING".ToSafeAlias();
|
||||
var output = "JUST-ANYTHING".ToSafeAlias(ShortStringHelper);
|
||||
Assert.AreEqual("SAFE-ALIAS::JUST-ANYTHING", output);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToSafeAlias()
|
||||
{
|
||||
var output = "JUST-ANYTHING".ToSafeAlias();
|
||||
var output = "JUST-ANYTHING".ToSafeAlias(ShortStringHelper);
|
||||
Assert.AreEqual("SAFE-ALIAS::JUST-ANYTHING", output);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToSafeAliasWithCulture()
|
||||
{
|
||||
var output = "JUST-ANYTHING".ToSafeAlias((string)null);
|
||||
var output = "JUST-ANYTHING".ToSafeAlias(ShortStringHelper, (string)null);
|
||||
Assert.AreEqual("SAFE-ALIAS-CULTURE::JUST-ANYTHING", output);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToUrlSegment()
|
||||
{
|
||||
var output = "JUST-ANYTHING".ToUrlSegment();
|
||||
var output = "JUST-ANYTHING".ToUrlSegment(ShortStringHelper);
|
||||
Assert.AreEqual("URL-SEGMENT::JUST-ANYTHING", output);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToUrlSegmentWithCulture()
|
||||
{
|
||||
var output = "JUST-ANYTHING".ToUrlSegment((string)null);
|
||||
var output = "JUST-ANYTHING".ToUrlSegment(ShortStringHelper, (string)null);
|
||||
Assert.AreEqual("URL-SEGMENT-CULTURE::JUST-ANYTHING", output);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToSafeFileName()
|
||||
{
|
||||
var output = "JUST-ANYTHING".ToSafeFileName();
|
||||
var output = "JUST-ANYTHING".ToSafeFileName(ShortStringHelper);
|
||||
Assert.AreEqual("SAFE-FILE-NAME::JUST-ANYTHING", output);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToSafeFileNameWithCulture()
|
||||
{
|
||||
var output = "JUST-ANYTHING".ToSafeFileName(null);
|
||||
var output = "JUST-ANYTHING".ToSafeFileName(ShortStringHelper, null);
|
||||
Assert.AreEqual("SAFE-FILE-NAME-CULTURE::JUST-ANYTHING", output);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertCase()
|
||||
{
|
||||
var output = "JUST-ANYTHING".ToCleanString(CleanStringType.Unchanged);
|
||||
var output = "JUST-ANYTHING".ToCleanString(ShortStringHelper, CleanStringType.Unchanged);
|
||||
Assert.AreEqual("CLEAN-STRING-A::JUST-ANYTHING", output);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SplitPascalCasing()
|
||||
{
|
||||
var output = "JUST-ANYTHING".SplitPascalCasing();
|
||||
var output = "JUST-ANYTHING".SplitPascalCasing(ShortStringHelper);
|
||||
Assert.AreEqual("SPLIT-PASCAL-CASING::JUST-ANYTHING", output);
|
||||
}
|
||||
|
||||
|
||||
@@ -269,6 +269,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
Logger,
|
||||
Factory.GetInstance<IGlobalSettings>(),
|
||||
HostingEnvironment,
|
||||
ShortStringHelper,
|
||||
new SiteDomainHelper(),
|
||||
Factory.GetInstance<IEntityXmlSerializer>(),
|
||||
ContentTypesCache,
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Umbraco.Tests.Testing
|
||||
protected Lazy<PropertyEditorCollection> PropertyEditorCollection => new Lazy<PropertyEditorCollection>(() => Factory.GetInstance<PropertyEditorCollection>());
|
||||
protected ILocalizationService LocalizationService => Factory.GetInstance<ILocalizationService>();
|
||||
protected ILocalizedTextService LocalizedTextService { get; private set; }
|
||||
protected IShortStringHelper ShortStringHelper { get; private set; }
|
||||
protected IShortStringHelper ShortStringHelper => Factory?.GetInstance<IShortStringHelper>() ?? TestHelper.ShortStringHelper;
|
||||
protected IUmbracoVersion UmbracoVersion { get; private set; }
|
||||
|
||||
protected ITypeFinder TypeFinder { get; private set; }
|
||||
@@ -159,7 +159,7 @@ namespace Umbraco.Tests.Testing
|
||||
var (logger, profiler) = GetLoggers(Options.Logger);
|
||||
var proflogger = new ProfilingLogger(logger, profiler);
|
||||
IOHelper = TestHelper.IOHelper;
|
||||
ShortStringHelper = TestHelper.ShortStringHelper;
|
||||
|
||||
|
||||
TypeFinder = new TypeFinder(logger);
|
||||
var appCaches = GetAppCaches();
|
||||
@@ -182,7 +182,7 @@ namespace Umbraco.Tests.Testing
|
||||
Composition = new Composition(register, typeLoader, proflogger, ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.GetConfigs(), TestHelper.IOHelper, AppCaches.NoCache);
|
||||
|
||||
|
||||
Composition.RegisterUnique(ShortStringHelper);
|
||||
|
||||
Composition.RegisterUnique(IOHelper);
|
||||
Composition.RegisterUnique(UmbracoVersion);
|
||||
Composition.RegisterUnique(TypeFinder);
|
||||
@@ -196,6 +196,8 @@ namespace Umbraco.Tests.Testing
|
||||
Composition.RegisterUnique(backOfficeInfo);
|
||||
Composition.RegisterUnique(ipResolver);
|
||||
Composition.RegisterUnique<IPasswordHasher, AspNetPasswordHasher>();
|
||||
Composition.RegisterUnique(TestHelper.ShortStringHelper);
|
||||
|
||||
|
||||
TestObjects = new TestObjects(register);
|
||||
Compose();
|
||||
@@ -397,10 +399,11 @@ namespace Umbraco.Tests.Testing
|
||||
// register filesystems
|
||||
Composition.RegisterUnique(factory => TestObjects.GetFileSystemsMock());
|
||||
|
||||
|
||||
var logger = Mock.Of<ILogger>();
|
||||
var scheme = Mock.Of<IMediaPathScheme>();
|
||||
|
||||
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), scheme, logger, ShortStringHelper);
|
||||
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), scheme, logger, TestHelper.ShortStringHelper);
|
||||
Composition.RegisterUnique<IMediaFileSystem>(factory => mediaFileSystem);
|
||||
|
||||
// no factory (noop)
|
||||
|
||||
@@ -267,7 +267,8 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper);
|
||||
helper,
|
||||
ShortStringHelper);
|
||||
|
||||
return controller;
|
||||
}
|
||||
@@ -301,7 +302,8 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper);
|
||||
helper,
|
||||
ShortStringHelper);
|
||||
|
||||
return controller;
|
||||
}
|
||||
@@ -343,7 +345,8 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper);
|
||||
helper,
|
||||
ShortStringHelper);
|
||||
|
||||
return controller;
|
||||
}
|
||||
@@ -390,7 +393,8 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper);
|
||||
helper,
|
||||
ShortStringHelper);
|
||||
|
||||
return controller;
|
||||
}
|
||||
@@ -429,7 +433,8 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper);
|
||||
helper,
|
||||
ShortStringHelper);
|
||||
|
||||
return controller;
|
||||
}
|
||||
@@ -474,7 +479,8 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper);
|
||||
helper,
|
||||
ShortStringHelper);
|
||||
|
||||
return controller;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,8 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
Factory.GetInstance<IMediaFileSystem>()
|
||||
Factory.GetInstance<IMediaFileSystem>(),
|
||||
ShortStringHelper
|
||||
);
|
||||
return usersController;
|
||||
}
|
||||
@@ -152,7 +153,8 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
Factory.GetInstance<IMediaFileSystem>());
|
||||
Factory.GetInstance<IMediaFileSystem>(),
|
||||
ShortStringHelper);
|
||||
return usersController;
|
||||
}
|
||||
|
||||
@@ -188,7 +190,8 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
Factory.GetInstance<IMediaFileSystem>());
|
||||
Factory.GetInstance<IMediaFileSystem>(),
|
||||
ShortStringHelper);
|
||||
return usersController;
|
||||
}
|
||||
|
||||
@@ -259,7 +262,8 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
Factory.GetInstance<IMediaFileSystem>());
|
||||
Factory.GetInstance<IMediaFileSystem>(),
|
||||
ShortStringHelper);
|
||||
return usersController;
|
||||
}
|
||||
|
||||
|
||||
@@ -427,6 +427,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
new TestDefaultCultureAccessor(),
|
||||
Current.Logger, TestObjects.GetGlobalSettings(),
|
||||
TestHelper.GetHostingEnvironment(),
|
||||
ShortStringHelper,
|
||||
new SiteDomainHelper(),
|
||||
Factory.GetInstance<IEntityXmlSerializer>(),
|
||||
null, true, false
|
||||
|
||||
@@ -14,6 +14,7 @@ using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.Strings.Css;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
@@ -33,9 +34,21 @@ namespace Umbraco.Web.Editors
|
||||
[UmbracoApplicationAuthorize(Core.Constants.Applications.Settings)]
|
||||
public class CodeFileController : BackOfficeNotificationsController
|
||||
{
|
||||
public CodeFileController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper)
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
|
||||
public CodeFileController(
|
||||
IGlobalSettings globalSettings,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
ISqlContext sqlContext,
|
||||
ServiceContext services,
|
||||
AppCaches appCaches,
|
||||
IProfilingLogger logger,
|
||||
IRuntimeState runtimeState,
|
||||
UmbracoHelper umbracoHelper,
|
||||
IShortStringHelper shortStringHelper)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
|
||||
{
|
||||
_shortStringHelper = shortStringHelper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -229,7 +242,7 @@ namespace Umbraco.Web.Editors
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
return snippets.Select(snippet => new SnippetDisplay() {Name = snippet.SplitPascalCasing().ToFirstUpperInvariant(), FileName = snippet});
|
||||
return snippets.Select(snippet => new SnippetDisplay() {Name = snippet.SplitPascalCasing(_shortStringHelper).ToFirstUpperInvariant(), FileName = snippet});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -36,6 +36,7 @@ using Umbraco.Core.Security;
|
||||
using Umbraco.Web.Routing;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
using Umbraco.Core.Dictionary;
|
||||
using Umbraco.Core.Strings;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
@@ -56,8 +57,19 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
public object Domains { get; private set; }
|
||||
|
||||
public ContentController(ICultureDictionary cultureDictionary, PropertyEditorCollection propertyEditors, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper)
|
||||
: base(cultureDictionary, globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
|
||||
public ContentController(
|
||||
ICultureDictionary cultureDictionary,
|
||||
PropertyEditorCollection propertyEditors,
|
||||
IGlobalSettings globalSettings,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
ISqlContext sqlContext,
|
||||
ServiceContext services,
|
||||
AppCaches appCaches,
|
||||
IProfilingLogger logger,
|
||||
IRuntimeState runtimeState,
|
||||
UmbracoHelper umbracoHelper,
|
||||
IShortStringHelper shortStringHelper)
|
||||
: base(cultureDictionary, globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, shortStringHelper)
|
||||
{
|
||||
_propertyEditors = propertyEditors ?? throw new ArgumentNullException(nameof(propertyEditors));
|
||||
_allLangs = new Lazy<IDictionary<string, ILanguage>>(() => Services.LocalizationService.GetAllLanguages().ToDictionary(x => x.IsoCode, x => x, StringComparer.InvariantCultureIgnoreCase));
|
||||
|
||||
@@ -13,6 +13,7 @@ using Umbraco.Core.Models.Editors;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.WebApi;
|
||||
@@ -28,11 +29,23 @@ namespace Umbraco.Web.Editors
|
||||
public abstract class ContentControllerBase : BackOfficeNotificationsController
|
||||
{
|
||||
protected ICultureDictionary CultureDictionary { get; }
|
||||
public IShortStringHelper ShortStringHelper { get; }
|
||||
|
||||
protected ContentControllerBase(ICultureDictionary cultureDictionary, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper)
|
||||
protected ContentControllerBase(
|
||||
ICultureDictionary cultureDictionary,
|
||||
IGlobalSettings globalSettings,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
ISqlContext sqlContext,
|
||||
ServiceContext services,
|
||||
AppCaches appCaches,
|
||||
IProfilingLogger logger,
|
||||
IRuntimeState runtimeState,
|
||||
UmbracoHelper umbracoHelper,
|
||||
IShortStringHelper shortStringHelper)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
|
||||
{
|
||||
CultureDictionary = cultureDictionary;
|
||||
ShortStringHelper = shortStringHelper;
|
||||
}
|
||||
|
||||
protected HttpResponseMessage HandleContentNotFound(object id, bool throwException = true)
|
||||
@@ -84,7 +97,7 @@ namespace Umbraco.Web.Editors
|
||||
.ToArray();
|
||||
|
||||
foreach (var file in files)
|
||||
file.FileName = file.FileName.ToSafeFileName();
|
||||
file.FileName = file.FileName.ToSafeFileName(ShortStringHelper);
|
||||
|
||||
// create the property data for the property editor
|
||||
var data = new ContentPropertyData(propertyDto.Value, propertyDto.DataType.Configuration)
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace Umbraco.Web.Editors
|
||||
// create item doctype
|
||||
var itemDocType = new ContentType(_shortStringHelper, parentId);
|
||||
itemDocType.Name = collectionItemName;
|
||||
itemDocType.Alias = collectionItemName.ToSafeAlias(true);
|
||||
itemDocType.Alias = collectionItemName.ToSafeAlias(_shortStringHelper, true);
|
||||
itemDocType.Icon = collectionItemIcon;
|
||||
|
||||
// create item doctype template
|
||||
@@ -247,7 +247,7 @@ namespace Umbraco.Web.Editors
|
||||
// create collection doctype
|
||||
var collectionDocType = new ContentType(_shortStringHelper, parentId);
|
||||
collectionDocType.Name = collectionName;
|
||||
collectionDocType.Alias = collectionName.ToSafeAlias(true);
|
||||
collectionDocType.Alias = collectionName.ToSafeAlias(_shortStringHelper, true);
|
||||
collectionDocType.Icon = collectionIcon;
|
||||
collectionDocType.IsContainer = true;
|
||||
collectionDocType.AllowedContentTypes = new List<ContentTypeSort>()
|
||||
|
||||
@@ -17,6 +17,7 @@ using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.Security;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
|
||||
@@ -30,6 +31,7 @@ namespace Umbraco.Web.Editors
|
||||
public class CurrentUserController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
private readonly IMediaFileSystem _mediaFileSystem;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
|
||||
public CurrentUserController(
|
||||
IGlobalSettings globalSettings,
|
||||
@@ -40,10 +42,12 @@ namespace Umbraco.Web.Editors
|
||||
IProfilingLogger logger,
|
||||
IRuntimeState runtimeState,
|
||||
UmbracoHelper umbracoHelper,
|
||||
IMediaFileSystem mediaFileSystem)
|
||||
IMediaFileSystem mediaFileSystem,
|
||||
IShortStringHelper shortStringHelper)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
|
||||
{
|
||||
_mediaFileSystem = mediaFileSystem;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -177,7 +181,7 @@ namespace Umbraco.Web.Editors
|
||||
public async Task<HttpResponseMessage> PostSetAvatar()
|
||||
{
|
||||
//borrow the logic from the user controller
|
||||
return await UsersController.PostSetAvatarInternal(Request, Services.UserService, AppCaches.RuntimeCache, _mediaFileSystem, Security.GetUserId().ResultOr(0));
|
||||
return await UsersController.PostSetAvatarInternal(Request, Services.UserService, AppCaches.RuntimeCache, _mediaFileSystem, _shortStringHelper, Security.GetUserId().ResultOr(0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -17,6 +17,7 @@ using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Dashboards;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.Services;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
@@ -32,15 +33,28 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
private readonly IDashboardService _dashboardService;
|
||||
private readonly IUmbracoVersion _umbracoVersion;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DashboardController"/> with all its dependencies.
|
||||
/// </summary>
|
||||
public DashboardController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, IDashboardService dashboardService, UmbracoHelper umbracoHelper, IUmbracoVersion umbracoVersion)
|
||||
public DashboardController(
|
||||
IGlobalSettings globalSettings,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
ISqlContext sqlContext,
|
||||
ServiceContext services,
|
||||
AppCaches appCaches,
|
||||
IProfilingLogger logger,
|
||||
IRuntimeState runtimeState,
|
||||
IDashboardService dashboardService,
|
||||
UmbracoHelper umbracoHelper,
|
||||
IUmbracoVersion umbracoVersion,
|
||||
IShortStringHelper shortStringHelper)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
|
||||
{
|
||||
_dashboardService = dashboardService;
|
||||
_umbracoVersion = umbracoVersion;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
}
|
||||
|
||||
//we have just one instance of HttpClient shared for the entire application
|
||||
@@ -155,7 +169,7 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
|
||||
//Make remote call to fetch videos or remote dashboard feed data
|
||||
var key = $"umbraco-XML-feed-{site}-{url.ToCleanString(Core.Strings.CleanStringType.UrlSegment)}";
|
||||
var key = $"umbraco-XML-feed-{site}-{url.ToCleanString(_shortStringHelper, CleanStringType.UrlSegment)}";
|
||||
|
||||
var content = AppCaches.RuntimeCache.GetCacheItem<string>(key);
|
||||
var result = string.Empty;
|
||||
|
||||
@@ -20,6 +20,7 @@ using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.Xml;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Models.Mapping;
|
||||
@@ -50,15 +51,28 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
private readonly ITreeService _treeService;
|
||||
private readonly UmbracoTreeSearcher _treeSearcher;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
private readonly SearchableTreeCollection _searchableTreeCollection;
|
||||
|
||||
public EntityController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState,
|
||||
ITreeService treeService, UmbracoHelper umbracoHelper, SearchableTreeCollection searchableTreeCollection, UmbracoTreeSearcher treeSearcher)
|
||||
public EntityController(
|
||||
IGlobalSettings globalSettings,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
ISqlContext sqlContext,
|
||||
ServiceContext services,
|
||||
AppCaches appCaches,
|
||||
IProfilingLogger logger,
|
||||
IRuntimeState runtimeState,
|
||||
ITreeService treeService,
|
||||
UmbracoHelper umbracoHelper,
|
||||
SearchableTreeCollection searchableTreeCollection,
|
||||
UmbracoTreeSearcher treeSearcher,
|
||||
IShortStringHelper shortStringHelper)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
|
||||
{
|
||||
_treeService = treeService;
|
||||
_searchableTreeCollection = searchableTreeCollection;
|
||||
_treeSearcher = treeSearcher;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -88,7 +102,7 @@ namespace Umbraco.Web.Editors
|
||||
/// <returns></returns>
|
||||
public dynamic GetSafeAlias(string value, bool camelCase = true)
|
||||
{
|
||||
var returnValue = string.IsNullOrWhiteSpace(value) ? string.Empty : value.ToSafeAlias(camelCase);
|
||||
var returnValue = string.IsNullOrWhiteSpace(value) ? string.Empty : value.ToSafeAlias(_shortStringHelper, camelCase);
|
||||
dynamic returnObj = new System.Dynamic.ExpandoObject();
|
||||
returnObj.alias = returnValue;
|
||||
returnObj.original = value;
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
var macro = new Macro(_shortStringHelper)
|
||||
{
|
||||
Alias = macroName.ToSafeAlias(),
|
||||
Alias = macroName.ToSafeAlias(_shortStringHelper),
|
||||
Name = macroName,
|
||||
MacroSource = model.VirtualPath.EnsureStartsWith("~"),
|
||||
MacroType = MacroTypes.PartialView
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Umbraco.Web.Editors
|
||||
return this.ReturnErrorResponse("Name can not be empty");
|
||||
}
|
||||
|
||||
var alias = name.ToSafeAlias();
|
||||
var alias = name.ToSafeAlias(_shortStringHelper);
|
||||
|
||||
if (_macroService.GetByAlias(alias) != null)
|
||||
{
|
||||
|
||||
@@ -64,11 +64,10 @@ namespace Umbraco.Web.Editors
|
||||
UmbracoHelper umbracoHelper,
|
||||
IMediaFileSystem mediaFileSystem,
|
||||
IShortStringHelper shortStringHelper)
|
||||
: base(cultureDictionary, globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
|
||||
: base(cultureDictionary, globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, shortStringHelper)
|
||||
{
|
||||
_propertyEditors = propertyEditors ?? throw new ArgumentNullException(nameof(propertyEditors));
|
||||
_mediaFileSystem = mediaFileSystem;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -253,7 +252,7 @@ namespace Umbraco.Web.Editors
|
||||
private int[] _userStartNodes;
|
||||
private readonly PropertyEditorCollection _propertyEditors;
|
||||
private readonly IMediaFileSystem _mediaFileSystem;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
|
||||
|
||||
protected int[] UserStartNodes
|
||||
{
|
||||
@@ -713,7 +712,7 @@ namespace Umbraco.Web.Editors
|
||||
foreach (var file in result.FileData)
|
||||
{
|
||||
var fileName = file.Headers.ContentDisposition.FileName.Trim(new[] { '\"' }).TrimEnd();
|
||||
var safeFileName = fileName.ToSafeFileName();
|
||||
var safeFileName = fileName.ToSafeFileName(ShortStringHelper);
|
||||
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
|
||||
|
||||
if (Current.Configs.Settings().Content.IsFileAllowedForUpload(ext))
|
||||
@@ -741,7 +740,7 @@ namespace Umbraco.Web.Editors
|
||||
if (fs == null) throw new InvalidOperationException("Could not acquire file stream");
|
||||
using (fs)
|
||||
{
|
||||
f.SetValue(_mediaFileSystem, _shortStringHelper, Services.ContentTypeBaseServices, Constants.Conventions.Media.File,fileName, fs);
|
||||
f.SetValue(_mediaFileSystem, ShortStringHelper, Services.ContentTypeBaseServices, Constants.Conventions.Media.File,fileName, fs);
|
||||
}
|
||||
|
||||
var saveResult = mediaService.Save(f, Security.CurrentUser.Id);
|
||||
|
||||
@@ -31,6 +31,7 @@ using Umbraco.Core.Dictionary;
|
||||
using Umbraco.Web.Security;
|
||||
using Umbraco.Core.Security;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core.Strings;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
@@ -43,8 +44,20 @@ namespace Umbraco.Web.Editors
|
||||
[OutgoingNoHyphenGuidFormat]
|
||||
public class MemberController : ContentControllerBase
|
||||
{
|
||||
public MemberController(IMemberPasswordConfiguration passwordConfig, ICultureDictionary cultureDictionary, PropertyEditorCollection propertyEditors, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper)
|
||||
: base(cultureDictionary, globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
|
||||
public MemberController(
|
||||
IMemberPasswordConfiguration passwordConfig,
|
||||
ICultureDictionary cultureDictionary,
|
||||
PropertyEditorCollection propertyEditors,
|
||||
IGlobalSettings globalSettings,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
ISqlContext sqlContext,
|
||||
ServiceContext services,
|
||||
AppCaches appCaches,
|
||||
IProfilingLogger logger,
|
||||
IRuntimeState runtimeState,
|
||||
UmbracoHelper umbracoHelper,
|
||||
IShortStringHelper shortStringHelper)
|
||||
: base(cultureDictionary, globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, shortStringHelper)
|
||||
{
|
||||
_passwordConfig = passwordConfig ?? throw new ArgumentNullException(nameof(passwordConfig));
|
||||
_propertyEditors = propertyEditors ?? throw new ArgumentNullException(nameof(propertyEditors));
|
||||
@@ -285,7 +298,7 @@ namespace Umbraco.Web.Editors
|
||||
IsApproved = contentItem.IsApproved
|
||||
};
|
||||
|
||||
return member;
|
||||
return member;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -12,6 +12,7 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.WebApi;
|
||||
@@ -28,9 +29,21 @@ namespace Umbraco.Web.Editors
|
||||
[EnableOverrideAuthorization]
|
||||
public class RelationTypeController : BackOfficeNotificationsController
|
||||
{
|
||||
public RelationTypeController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper)
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
|
||||
public RelationTypeController(
|
||||
IGlobalSettings globalSettings,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
ISqlContext sqlContext,
|
||||
ServiceContext services,
|
||||
AppCaches appCaches,
|
||||
IProfilingLogger logger,
|
||||
IRuntimeState runtimeState,
|
||||
UmbracoHelper umbracoHelper,
|
||||
IShortStringHelper shortStringHelper)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
|
||||
{
|
||||
_shortStringHelper = shortStringHelper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -48,7 +61,7 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
|
||||
var display = Mapper.Map<IRelationType, RelationTypeDisplay>(relationType);
|
||||
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
@@ -100,7 +113,7 @@ namespace Umbraco.Web.Editors
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the persisted relation type's ID.</returns>
|
||||
public HttpResponseMessage PostCreate(RelationTypeSave relationType)
|
||||
{
|
||||
var relationTypePersisted = new RelationType(relationType.Name, relationType.Name.ToSafeAlias(true), relationType.IsBidirectional, relationType.ChildObjectType, relationType.ParentObjectType);
|
||||
var relationTypePersisted = new RelationType(relationType.Name, relationType.Name.ToSafeAlias(_shortStringHelper, true), relationType.IsBidirectional, relationType.ChildObjectType, relationType.ParentObjectType);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.WebApi;
|
||||
@@ -27,12 +28,14 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
private IMediaService _mediaService;
|
||||
private IContentTypeBaseServiceProvider _contentTypeBaseServiceProvider;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
|
||||
|
||||
public TinyMceController(IMediaService mediaService, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider)
|
||||
public TinyMceController(IMediaService mediaService, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, IShortStringHelper shortStringHelper)
|
||||
{
|
||||
_mediaService = mediaService;
|
||||
_contentTypeBaseServiceProvider = contentTypeBaseServiceProvider;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@@ -75,7 +78,7 @@ namespace Umbraco.Web.Editors
|
||||
// Really we should only have one file per request to this endpoint
|
||||
var file = result.FileData[0];
|
||||
var fileName = file.Headers.ContentDisposition.FileName.Trim(new[] { '\"' }).TrimEnd();
|
||||
var safeFileName = fileName.ToSafeFileName();
|
||||
var safeFileName = fileName.ToSafeFileName(_shortStringHelper);
|
||||
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
|
||||
|
||||
if (Current.Configs.Settings().Content.IsFileAllowedForUpload(ext) == false || Current.Configs.Settings().Content.ImageFileTypes.Contains(ext) == false)
|
||||
|
||||
@@ -24,6 +24,7 @@ using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.Editors.Filters;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Mvc;
|
||||
@@ -43,12 +44,24 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly IMediaFileSystem _mediaFileSystem;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
|
||||
public UsersController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, IMediaFileSystem mediaFileSystem)
|
||||
public UsersController(
|
||||
IGlobalSettings globalSettings,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
ISqlContext sqlContext,
|
||||
ServiceContext services,
|
||||
AppCaches appCaches,
|
||||
IProfilingLogger logger,
|
||||
IRuntimeState runtimeState,
|
||||
UmbracoHelper umbracoHelper,
|
||||
IMediaFileSystem mediaFileSystem,
|
||||
IShortStringHelper shortStringHelper)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
|
||||
{
|
||||
_globalSettings = globalSettings;
|
||||
_mediaFileSystem = mediaFileSystem;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -69,10 +82,10 @@ namespace Umbraco.Web.Editors
|
||||
[AdminUsersAuthorize]
|
||||
public async Task<HttpResponseMessage> PostSetAvatar(int id)
|
||||
{
|
||||
return await PostSetAvatarInternal(Request, Services.UserService, AppCaches.RuntimeCache, _mediaFileSystem, id);
|
||||
return await PostSetAvatarInternal(Request, Services.UserService, AppCaches.RuntimeCache, _mediaFileSystem, _shortStringHelper, id);
|
||||
}
|
||||
|
||||
internal static async Task<HttpResponseMessage> PostSetAvatarInternal(HttpRequestMessage request, IUserService userService, IAppCache cache, IMediaFileSystem mediaFileSystem, int id)
|
||||
internal static async Task<HttpResponseMessage> PostSetAvatarInternal(HttpRequestMessage request, IUserService userService, IAppCache cache, IMediaFileSystem mediaFileSystem, IShortStringHelper shortStringHelper, int id)
|
||||
{
|
||||
if (request.Content.IsMimeMultipartContent() == false)
|
||||
{
|
||||
@@ -104,7 +117,7 @@ namespace Umbraco.Web.Editors
|
||||
//get the file info
|
||||
var file = result.FileData[0];
|
||||
var fileName = file.Headers.ContentDisposition.FileName.Trim(new[] { '\"' }).TrimEnd();
|
||||
var safeFileName = fileName.ToSafeFileName();
|
||||
var safeFileName = fileName.ToSafeFileName(shortStringHelper);
|
||||
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
|
||||
|
||||
if (Current.Configs.Settings().Content.DisallowedUploadFiles.Contains(ext) == false)
|
||||
|
||||
@@ -11,6 +11,7 @@ using Umbraco.Core.Composing;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Routing;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Strings;
|
||||
using Current = Umbraco.Web.Composing.Current;
|
||||
using Umbraco.Web.Features;
|
||||
|
||||
@@ -27,19 +28,22 @@ namespace Umbraco.Web.Mvc
|
||||
}
|
||||
|
||||
private readonly IControllerFactory _controllerFactory;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly UmbracoContext _umbracoContext;
|
||||
|
||||
public RenderRouteHandler(IUmbracoContextAccessor umbracoContextAccessor, IControllerFactory controllerFactory)
|
||||
public RenderRouteHandler(IUmbracoContextAccessor umbracoContextAccessor, IControllerFactory controllerFactory, IShortStringHelper shortStringHelper)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
_controllerFactory = controllerFactory ?? throw new ArgumentNullException(nameof(controllerFactory));
|
||||
_shortStringHelper = shortStringHelper ?? throw new ArgumentNullException(nameof(shortStringHelper));
|
||||
}
|
||||
|
||||
public RenderRouteHandler(UmbracoContext umbracoContext, IControllerFactory controllerFactory)
|
||||
public RenderRouteHandler(UmbracoContext umbracoContext, IControllerFactory controllerFactory, IShortStringHelper shortStringHelper)
|
||||
{
|
||||
_umbracoContext = umbracoContext ?? throw new ArgumentNullException(nameof(umbracoContext));
|
||||
_controllerFactory = controllerFactory ?? throw new ArgumentNullException(nameof(controllerFactory));
|
||||
_shortStringHelper = shortStringHelper ?? throw new ArgumentNullException(nameof(shortStringHelper));
|
||||
}
|
||||
|
||||
private UmbracoContext UmbracoContext => _umbracoContext ?? _umbracoContextAccessor.UmbracoContext;
|
||||
@@ -262,7 +266,7 @@ namespace Umbraco.Web.Mvc
|
||||
//the template Alias should always be already saved with a safe name.
|
||||
//if there are hyphens in the name and there is a hijacked route, then the Action will need to be attributed
|
||||
// with the action name attribute.
|
||||
var templateName = request.TemplateAlias.Split('.')[0].ToSafeAlias();
|
||||
var templateName = request.TemplateAlias.Split('.')[0].ToSafeAlias(_shortStringHelper);
|
||||
def.ActionName = templateName;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
|
||||
var absoluteTempImagePath = _ioHelper.MapPath(tmpImgPath);
|
||||
var fileName = Path.GetFileName(absoluteTempImagePath);
|
||||
var safeFileName = fileName.ToSafeFileName();
|
||||
var safeFileName = fileName.ToSafeFileName(_shortStringHelper);
|
||||
|
||||
var mediaItemName = safeFileName.ToFriendlyName();
|
||||
IMedia mediaFile;
|
||||
|
||||
@@ -16,6 +16,7 @@ using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.Install;
|
||||
using Umbraco.Web.JavaScript;
|
||||
using Umbraco.Web.Mvc;
|
||||
@@ -34,8 +35,17 @@ namespace Umbraco.Web.Runtime
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
|
||||
public WebInitialComponent(IUmbracoContextAccessor umbracoContextAccessor, SurfaceControllerTypeCollection surfaceControllerTypes, UmbracoApiControllerTypeCollection apiControllerTypes, IHostingSettings hostingSettings, IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment, IIOHelper ioHelper)
|
||||
public WebInitialComponent(
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
SurfaceControllerTypeCollection surfaceControllerTypes,
|
||||
UmbracoApiControllerTypeCollection apiControllerTypes,
|
||||
IHostingSettings hostingSettings,
|
||||
IGlobalSettings globalSettings,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IIOHelper ioHelper,
|
||||
IShortStringHelper shortStringHelper)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_surfaceControllerTypes = surfaceControllerTypes;
|
||||
@@ -44,6 +54,7 @@ namespace Umbraco.Web.Runtime
|
||||
_globalSettings = globalSettings;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_ioHelper = ioHelper;
|
||||
_shortStringHelper = shortStringHelper;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
@@ -68,7 +79,7 @@ namespace Umbraco.Web.Runtime
|
||||
ConfigureGlobalFilters();
|
||||
|
||||
// set routes
|
||||
CreateRoutes(_umbracoContextAccessor, _globalSettings, _surfaceControllerTypes, _apiControllerTypes);
|
||||
CreateRoutes(_umbracoContextAccessor, _globalSettings, _shortStringHelper, _surfaceControllerTypes, _apiControllerTypes);
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
@@ -154,6 +165,7 @@ namespace Umbraco.Web.Runtime
|
||||
internal static void CreateRoutes(
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IGlobalSettings globalSettings,
|
||||
IShortStringHelper shortStringHelper,
|
||||
SurfaceControllerTypeCollection surfaceControllerTypes,
|
||||
UmbracoApiControllerTypeCollection apiControllerTypes)
|
||||
{
|
||||
@@ -165,7 +177,7 @@ namespace Umbraco.Web.Runtime
|
||||
umbracoPath + "/RenderMvc/{action}/{id}",
|
||||
new { controller = "RenderMvc", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
defaultRoute.RouteHandler = new RenderRouteHandler(umbracoContextAccessor, ControllerBuilder.Current.GetControllerFactory());
|
||||
defaultRoute.RouteHandler = new RenderRouteHandler(umbracoContextAccessor, ControllerBuilder.Current.GetControllerFactory(),shortStringHelper);
|
||||
|
||||
// register install routes
|
||||
RouteTable.Routes.RegisterArea<UmbracoInstallArea>();
|
||||
|
||||
@@ -12,6 +12,7 @@ using Umbraco.Web.Routing;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Web.Macros;
|
||||
using Current = Umbraco.Web.Composing.Current;
|
||||
|
||||
@@ -30,14 +31,16 @@ namespace Umbraco.Web.Templates
|
||||
private readonly IFileService _fileService;
|
||||
private readonly ILocalizationService _languageService;
|
||||
private readonly IWebRoutingSection _webRoutingSection;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
|
||||
public TemplateRenderer(IUmbracoContextAccessor umbracoContextAccessor, IPublishedRouter publishedRouter, IFileService fileService, ILocalizationService textService, IWebRoutingSection webRoutingSection)
|
||||
public TemplateRenderer(IUmbracoContextAccessor umbracoContextAccessor, IPublishedRouter publishedRouter, IFileService fileService, ILocalizationService textService, IWebRoutingSection webRoutingSection, IShortStringHelper shortStringHelper)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
_publishedRouter = publishedRouter ?? throw new ArgumentNullException(nameof(publishedRouter));
|
||||
_fileService = fileService ?? throw new ArgumentNullException(nameof(fileService));
|
||||
_languageService = textService ?? throw new ArgumentNullException(nameof(textService));
|
||||
_webRoutingSection = webRoutingSection ?? throw new ArgumentNullException(nameof(webRoutingSection));
|
||||
_shortStringHelper = shortStringHelper;
|
||||
}
|
||||
|
||||
public void Render(int pageId, int? altTemplateId, StringWriter writer)
|
||||
@@ -129,7 +132,7 @@ namespace Umbraco.Web.Templates
|
||||
{
|
||||
Route = RouteTable.Routes["Umbraco_default"]
|
||||
});
|
||||
var routeHandler = new RenderRouteHandler(_umbracoContextAccessor, ControllerBuilder.Current.GetControllerFactory());
|
||||
var routeHandler = new RenderRouteHandler(_umbracoContextAccessor, ControllerBuilder.Current.GetControllerFactory(), _shortStringHelper);
|
||||
var routeDef = routeHandler.GetUmbracoRouteDefinition(requestContext, request);
|
||||
var renderModel = new ContentModel(request.PublishedContent);
|
||||
//manually add the action/controller, this is required by mvc
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace Umbraco.Web
|
||||
var configFactory = new ConfigsFactory();
|
||||
|
||||
var hostingSettings = configFactory.HostingSettings;
|
||||
var coreDebug = configFactory.CoreDebug;
|
||||
|
||||
_hostingEnvironment = new AspNetHostingEnvironment(hostingSettings);
|
||||
_ioHelper = new IOHelper(_hostingEnvironment);
|
||||
@@ -46,7 +47,7 @@ namespace Umbraco.Web
|
||||
|
||||
_profiler = new LogProfiler(_logger);
|
||||
|
||||
_logger = SerilogLogger.CreateWithDefaultConfiguration(_hostingEnvironment, new AspNetSessionIdResolver(), () => _factory?.GetInstance<IRequestCache>(), _configs.CoreDebug(), _ioHelper, new FrameworkMarchal());
|
||||
_logger = SerilogLogger.CreateWithDefaultConfiguration(_hostingEnvironment, new AspNetSessionIdResolver(), () => _factory?.GetInstance<IRequestCache>(), coreDebug, _ioHelper, new FrameworkMarchal());
|
||||
_backOfficeInfo = new AspNetBackOfficeInfo(_configs.Global(), _ioHelper, _configs.Settings(), _logger);
|
||||
|
||||
Umbraco.Composing.Current.Logger = _logger;
|
||||
|
||||
Reference in New Issue
Block a user