Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions src/Umbraco.Core/IO/ShadowFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Umbraco.Cms.Core.IO;

internal sealed class ShadowFileSystem : IFileSystem
internal sealed partial class ShadowFileSystem : IFileSystem
{
private readonly IFileSystem _sfs;

Expand Down Expand Up @@ -392,14 +392,28 @@ private void Delete(string path, bool recurse)
}

// copied from System.Web.Util.Wildcard internal
internal sealed class WildcardExpression
internal sealed partial class WildcardExpression
{
private static readonly Regex MetaRegex = new("[\\+\\{\\\\\\[\\|\\(\\)\\.\\^\\$]");
private static readonly Regex QuestRegex = new("\\?");
private static readonly Regex StarRegex = new("\\*");
private static readonly Regex CommaRegex = new(",");
private static readonly Regex SlashRegex = new("(?=/)");
private static readonly Regex BackslashRegex = new("(?=[\\\\:])");
private static readonly Regex MetaRegex = GetMetaRegex();

[GeneratedRegex("[\\+\\{\\\\\\[\\|\\(\\)\\.\\^\\$]")]
private static partial Regex GetMetaRegex();

private static readonly Regex QuestRegex = GetQuestRegex();

[GeneratedRegex("\\?")]
private static partial Regex GetQuestRegex();

private static readonly Regex StarRegex = GetStarRegex();

[GeneratedRegex("\\*")]
private static partial Regex GetStarRegex();

private static readonly Regex CommaRegex = GetCommaRegex();

[GeneratedRegex(",")]
private static partial Regex GetCommaRegex();

private readonly bool _caseInsensitive;
private readonly string _pattern;
private Regex? _regex;
Expand Down
6 changes: 3 additions & 3 deletions src/Umbraco.Core/Templates/HtmlLocalLinkParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public sealed class HtmlLocalLinkParser
// <a type="document" href="/{localLink:eed5fc6b-96fd-45a5-a0f1-b1adfb483c2f}" title="other page">other page</a>
internal static readonly Regex LocalLinkTagPattern = new(
@"<a.+?href=['""](?<locallink>\/?{localLink:(?<guid>[a-fA-F0-9-]+)})[^>]*?>",
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline);
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline | RegexOptions.Compiled);

internal static readonly Regex TypePattern = new(
"""type=['"](?<type>(?:media|document))['"]""",
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled);

internal static readonly Regex LocalLinkPattern = new(
@"href=['""](?<locallink>\/?(?:\{|\%7B)localLink:(?<guid>[a-zA-Z0-9-://]+)(?:\}|\%7D))",
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled);

private readonly IPublishedUrlProvider _publishedUrlProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,18 @@ public static RecordPersistenceType InsertOrUpdate<T>(
/// <returns></returns>
public static string EscapeAtSymbols(string value)
{
if (value.Contains("@") == false)
if (value.Contains('@') == false)
{
return value;
}

// this fancy regex will only match a single @ not a double, etc...
var regex = new Regex("(?<!@)@(?!@)");
return regex.Replace(value, "@@");
return AtRegex().Replace(value, "@@");
}

[GeneratedRegex("(?<!@)@(?!@)")]
private static partial Regex AtRegex();

/// <summary>
/// Returns the underlying connection as a typed connection - this is used to unwrap the profiled mini profiler stuff
/// </summary>
Expand Down