From d943fbd83e87f6403cc407fae029682259d62fe8 Mon Sep 17 00:00:00 2001 From: Andrea Piovanelli <83577153+AndreaPiovanelliLaser@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:29:52 +0100 Subject: [PATCH] Added StringComparer and forced lowercase where needed to ensure matching paths to ignore casing. (#8743) --- .../Modules/Orchard.Autoroute/Services/AutorouteService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Autoroute/Services/AutorouteService.cs b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/AutorouteService.cs index b3b90f12e36..bcc568e19b0 100644 --- a/src/Orchard.Web/Modules/Orchard.Autoroute/Services/AutorouteService.cs +++ b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/AutorouteService.cs @@ -186,7 +186,7 @@ public void RemoveAliases(AutoroutePart part) { } public string GenerateUniqueSlug(AutoroutePart part, IEnumerable existingPaths) { - if (existingPaths == null || !existingPaths.Contains(part.Path)) + if (existingPaths == null || !existingPaths.Contains(part.Path, StringComparer.OrdinalIgnoreCase)) return part.Path; var version = existingPaths.Select(s => GetSlugVersion(part.Path, s)).OrderBy(i => i).LastOrDefault(); @@ -287,7 +287,8 @@ private string GetDefaultPatternIndex(string contentType, string culture) { private static int? GetSlugVersion(string path, string potentialConflictingPath) { int v; - var slugParts = potentialConflictingPath.Split(new[] { path }, StringSplitOptions.RemoveEmptyEntries); + // Matching needs to ignore case, so both paths are forced to lowercase. + var slugParts = potentialConflictingPath.ToLower().Split(new[] { path.ToLower() }, StringSplitOptions.RemoveEmptyEntries); if (slugParts.Length == 0) return 2;