Skip to content

Commit

Permalink
Merge branch 'v14/dev' into v15/dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	Directory.Packages.props
#	build/azure-pipelines.yml
#	src/Umbraco.Core/MonitorLock.cs
#	src/Umbraco.PublishedCache.NuCache/ContentStore.cs
#	src/Umbraco.PublishedCache.NuCache/DependencyInjection/UmbracoBuilderExtensions.cs
#	src/Umbraco.PublishedCache.NuCache/SnapDictionary.cs
#	src/Umbraco.Web.Common/Authorization/AuthorizationPolicies.cs
#	src/Umbraco.Web.UI.Client~v14_dev
#	tests/Umbraco.Tests.AcceptanceTest/package-lock.json
#	tests/Umbraco.Tests.AcceptanceTest/package.json
#	tests/Umbraco.Tests.AcceptanceTest/playwright.config.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCustomDataType.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowAtRoot.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowVaryByCulture.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowedChildNodes.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowedTemplates.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithCollections.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithListViewContent.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/DataTypeFolder.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/ListViewMedia.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/Media.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Members/MemberGroups.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/CreatedPackages.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/PackagesPackages.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithApprovedColor.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithCheckboxList.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithContentPicker.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithDatePicker.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithDropdown.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithImageCropper.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithNumeric.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithRadiobox.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTags.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextarea.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextstring.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTrueFalse.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeFolder.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeTemplatesTab.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/MediaType/MediaTypeFolder.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/PartialView/PartialViewFolder.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Script/Script.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Script/ScriptFolder.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Stylesheet/StylesheetFolder.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/ContentStartNodes.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/MediaStartNodes.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/UICulture.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/ContentStartNodes.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/DefaultPermissionsInContent.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/MediaStartNodes.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/MemberSection.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/User.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/UserGroups.spec.ts
  • Loading branch information
Migaroez committed Nov 27, 2024
2 parents 44ec0e6 + 28756d4 commit c2f16b7
Show file tree
Hide file tree
Showing 22 changed files with 397 additions and 117 deletions.
5 changes: 5 additions & 0 deletions src/Umbraco.Cms.Api.Common/Umbraco.Cms.Api.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<ItemGroup>
<!-- Take top-level depedendency on Microsoft.IdentityModel.JsonWebTokens, because OpenIddict.AspNetCore depends on a vulnerable version -->
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" />
<!-- Both OpenIddict.AspNetCore, Npoco.SqlServer and Microsoft.EntityFrameworkCore.SqlServer bring in a vulnerable version of Microsoft.IdentityModel.JsonWebTokens -->
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens"/>

<!-- Take top-level depedendency on OpenIddict.AspNetCore depends on a vulnerable version -->
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Globalization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Headers;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -49,16 +50,32 @@ public void Configure(ImageSharpMiddlewareOptions options)
return Task.CompletedTask;
}

int width = context.Parser.ParseValue<int>(context.Commands.GetValueOrDefault(ResizeWebProcessor.Width), context.Culture);
if (width <= 0 || width > _imagingSettings.Resize.MaxWidth)
if (context.Commands.Contains(ResizeWebProcessor.Width))
{
context.Commands.Remove(ResizeWebProcessor.Width);
if (!int.TryParse(
context.Commands.GetValueOrDefault(ResizeWebProcessor.Width),
NumberStyles.Integer,
CultureInfo.InvariantCulture,
out var width)
|| width < 0
|| width >= _imagingSettings.Resize.MaxWidth)
{
context.Commands.Remove(ResizeWebProcessor.Width);
}
}

int height = context.Parser.ParseValue<int>(context.Commands.GetValueOrDefault(ResizeWebProcessor.Height), context.Culture);
if (height <= 0 || height > _imagingSettings.Resize.MaxHeight)
if (context.Commands.Contains(ResizeWebProcessor.Height))
{
context.Commands.Remove(ResizeWebProcessor.Height);
if (!int.TryParse(
context.Commands.GetValueOrDefault(ResizeWebProcessor.Height),
NumberStyles.Integer,
CultureInfo.InvariantCulture,
out var height)
|| height < 0
|| height >= _imagingSettings.Resize.MaxHeight)
{
context.Commands.Remove(ResizeWebProcessor.Height);
}
}

return Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Globalization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Headers;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -47,20 +48,32 @@ public void Configure(ImageSharpMiddlewareOptions options)
return Task.CompletedTask;
}

var width = context.Parser.ParseValue<int>(
context.Commands.GetValueOrDefault(ResizeWebProcessor.Width),
context.Culture);
if (width <= 0 || width > _imagingSettings.Resize.MaxWidth)
if (context.Commands.Contains(ResizeWebProcessor.Width))
{
context.Commands.Remove(ResizeWebProcessor.Width);
if (!int.TryParse(
context.Commands.GetValueOrDefault(ResizeWebProcessor.Width),
NumberStyles.Integer,
CultureInfo.InvariantCulture,
out var width)
|| width < 0
|| width >= _imagingSettings.Resize.MaxWidth)
{
context.Commands.Remove(ResizeWebProcessor.Width);
}
}

var height = context.Parser.ParseValue<int>(
context.Commands.GetValueOrDefault(ResizeWebProcessor.Height),
context.Culture);
if (height <= 0 || height > _imagingSettings.Resize.MaxHeight)
if (context.Commands.Contains(ResizeWebProcessor.Height))
{
context.Commands.Remove(ResizeWebProcessor.Height);
if (!int.TryParse(
context.Commands.GetValueOrDefault(ResizeWebProcessor.Height),
NumberStyles.Integer,
CultureInfo.InvariantCulture,
out var height)
|| height < 0
|| height >= _imagingSettings.Resize.MaxHeight)
{
context.Commands.Remove(ResizeWebProcessor.Height);
}
}

return Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
</PropertyGroup>

<ItemGroup>
<!-- Take top-level depedendency on Azure.Identity, because Microsoft.EntityFrameworkCore.SqlServer depends on a vulnerable version -->
<PackageReference Include="Azure.Identity" />

<!-- Take top-level depedendency on Microsoft.Extensions.Caching.Memory, because Microsoft.EntityFrameworkCore.* depends on a vulnerable version -->
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />

<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
<PackageReference Include="OpenIddict.EntityFrameworkCore" />
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Core/Configuration/Models/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ internal const string
/// <summary>
/// Gets or sets a value indicating whether to install the database when it is missing.
/// </summary>
[Obsolete("This option will be removed in V16.")]
[DefaultValue(StaticInstallMissingDatabase)]
public bool InstallMissingDatabase { get; set; } = StaticInstallMissingDatabase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public RootDynamicRootOriginFinder(IEntityService entityService)
return null;
}

var entity = _entityService.Get(query.Context.ParentKey);
// when creating new content, CurrentKey will be null - fallback to using ParentKey
Guid entityKey = query.Context.CurrentKey ?? query.Context.ParentKey;
var entity = _entityService.Get(entityKey);

if (entity is null || _allowedObjectTypes.Contains(entity.NodeObjectType) is false)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ public SiteDynamicRootOriginFinder(IEntityService entityService, IDomainService

public override Guid? FindOriginKey(DynamicRootNodeQuery query)
{
if (query.OriginAlias != SupportedOriginType || query.Context.CurrentKey.HasValue is false)
if (query.OriginAlias != SupportedOriginType)
{
return null;
}

IEntitySlim? entity = _entityService.Get(query.Context.CurrentKey.Value);
// when creating new content, CurrentKey will be null - fallback to using ParentKey
Guid entityKey = query.Context.CurrentKey ?? query.Context.ParentKey;
IEntitySlim? entity = _entityService.Get(entityKey);
if (entity is null || entity.NodeObjectType != Constants.ObjectTypes.Document)
{
return null;
Expand Down
6 changes: 6 additions & 0 deletions src/Umbraco.Core/Routing/UriUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ public Uri UriToUmbraco(Uri uri)
if (path != "/")
{
path = path.TrimEnd(Constants.CharArrays.ForwardSlash);

// perform fallback to root if the path was all slashes (i.e. https://some.where//////)
if (path == string.Empty)
{
path = "/";
}
}

return uri.Rewrite(path);
Expand Down
16 changes: 16 additions & 0 deletions src/Umbraco.Core/Services/IContentService.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Membership;
using Umbraco.Cms.Core.Persistence.Querying;
Expand Down Expand Up @@ -315,6 +316,21 @@ public interface IContentService : IContentServiceBase<IContent>
/// </summary>
OperationResult Move(IContent content, int parentId, int userId = Constants.Security.SuperUserId);

/// <summary>
/// Attempts to move the <see cref="IContent"/> <paramref name="content"/> to under the node with id <paramref name="parentId"/>.
/// </summary>
/// <param name="content">The <see cref="IContent"/> that shall be moved.</param>
/// <param name="parentId">The id of the new parent node.</param>
/// <param name="userId">Id of the user attempting to move <paramref name="content"/>.</param>
/// <returns>Success if moving succeeded, otherwise Failed.</returns>
[Obsolete("Adds return type to Move method. Will be removed in V14, as the original method will be adjusted.")]
OperationResult
AttemptMove(IContent content, int parentId, int userId = Constants.Security.SuperUserId)
{
Move(content, parentId, userId);
return OperationResult.Succeed(new EventMessages());
}

/// <summary>
/// Copies a document.
/// </summary>
Expand Down
25 changes: 17 additions & 8 deletions src/Umbraco.Core/Services/LocalizedTextService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,13 @@ private IDictionary<string, IDictionary<string, string>> GetAreaStoredTranslatio
IEnumerable<XElement> areas = xmlSource[cult].Value.XPathSelectElements("//area");
foreach (XElement area in areas)
{
var result = new Dictionary<string, string>(StringComparer.InvariantCulture);
var areaAlias = area.Attribute("alias")!.Value;

if (!overallResult.TryGetValue(areaAlias, out IDictionary<string, string>? result))
{
result = new Dictionary<string, string>(StringComparer.InvariantCulture);
}

IEnumerable<XElement> keys = area.XPathSelectElements("./key");
foreach (XElement key in keys)
{
Expand All @@ -364,7 +370,10 @@ private IDictionary<string, IDictionary<string, string>> GetAreaStoredTranslatio
}
}

overallResult.Add(area.Attribute("alias")!.Value, result);
if (!overallResult.ContainsKey(areaAlias))
{
overallResult.Add(areaAlias, result);
}
}

// Merge English Dictionary
Expand All @@ -374,11 +383,11 @@ private IDictionary<string, IDictionary<string, string>> GetAreaStoredTranslatio
IEnumerable<XElement> enUS = xmlSource[englishCulture].Value.XPathSelectElements("//area");
foreach (XElement area in enUS)
{
IDictionary<string, string>
result = new Dictionary<string, string>(StringComparer.InvariantCulture);
if (overallResult.ContainsKey(area.Attribute("alias")!.Value))
var areaAlias = area.Attribute("alias")!.Value;

if (!overallResult.TryGetValue(areaAlias, out IDictionary<string, string>? result))
{
result = overallResult[area.Attribute("alias")!.Value];
result = new Dictionary<string, string>(StringComparer.InvariantCulture);
}

IEnumerable<XElement> keys = area.XPathSelectElements("./key");
Expand All @@ -394,9 +403,9 @@ private IDictionary<string, IDictionary<string, string>> GetAreaStoredTranslatio
}
}

if (!overallResult.ContainsKey(area.Attribute("alias")!.Value))
if (!overallResult.ContainsKey(areaAlias))
{
overallResult.Add(area.Attribute("alias")!.Value, result);
overallResult.Add(areaAlias, result);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;

namespace Umbraco.Cms.Core.Cache;

public class MemberRepositoryUsernameCachePolicy : DefaultRepositoryCachePolicy<IMember, string>
{
public MemberRepositoryUsernameCachePolicy(IAppPolicyCache cache, IScopeAccessor scopeAccessor, RepositoryCachePolicyOptions options) : base(cache, scopeAccessor, options)
{
}

public IMember? GetByUserName(string key, string? username, Func<string?, IMember?> performGetByUsername, Func<string[]?, IEnumerable<IMember>?> performGetAll)
{
var cacheKey = GetEntityCacheKey(key + username);
IMember? fromCache = Cache.GetCacheItem<IMember>(cacheKey);

// if found in cache then return else fetch and cache
if (fromCache != null)
{
return fromCache;
}

IMember? entity = performGetByUsername(username);

if (entity != null && entity.HasIdentity)
{
InsertEntity(cacheKey, entity);
}

return entity;
}
}
Loading

0 comments on commit c2f16b7

Please sign in to comment.