19 lines
1.0 KiB
C#
19 lines
1.0 KiB
C#
using System.Text.RegularExpressions;
|
|
namespace PlotLine.Services.Context;
|
|
|
|
// Only read-only main-page destinations are delegated. Destination controllers retain
|
|
// their normal entity/project authorisation. Never accept a general redirect URL.
|
|
public static partial class ContextWorkspaceNavigation
|
|
{
|
|
public static bool IsAllowed(string? url)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(url) || url.Length > 4096 || !url.StartsWith('/') ||
|
|
url.StartsWith("//") || url.Any(c => char.IsControl(c) || c == '\\')) return false;
|
|
var path = url.Split('?', '#')[0];
|
|
return MainPage().IsMatch(path);
|
|
}
|
|
|
|
[GeneratedRegex(@"^/(?:Characters(?:/(?:Details|Edit)/[1-9][0-9]*)?|Locations(?:/(?:Details|Edit)/[1-9][0-9]*)?|Maps|FloorPlans(?:/Edit/[1-9][0-9]*)?|Scenes/Edit/[1-9][0-9]*|Names|RelationshipMap|StoryCalendar|PlotLineWorkspace|PlotThreads/Edit/[1-9][0-9]*|Writer|Books/Details/[1-9][0-9]*|manuscript/paragraphs)/?$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)]
|
|
private static partial Regex MainPage();
|
|
}
|