починил поли(точно)

This commit is contained in:
Pupchansky
2024-10-11 07:23:29 +05:00
parent 606fc13a47
commit acd0040663

View File

@@ -3,6 +3,7 @@ using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Differencing;
using Robust.Server.ServerStatus;
namespace Content.Server.Administration;
@@ -64,7 +65,7 @@ public sealed partial class ServerApi
{
var absolute_path = context.Url.AbsolutePath;
if (context.RequestMethod != method || !CheckPathes(absolute_path))
if (context.RequestMethod != method || !CheckPathes(absolute_path, exactPath))
return false;
if (!await CheckAccess(context))
@@ -79,14 +80,26 @@ public sealed partial class ServerApi
});
}
private static bool CheckPathes(string realPath)
private static bool CheckPathes(string realPath, string predictedPath)
{
var search_regex = ParametrSearchRegex();
if (search_regex.IsMatch(realPath))
return true;
var is_match = search_regex.Matches(predictedPath)
.ToList()
.TrueForAll(match =>
{
if (!match.Success)
return false;
return false;
var to_replace = match.Groups[1].Value;
var inner_regex = new Regex(predictedPath.Replace(to_replace, "(.*)"));
var inner_match = inner_regex.Match(realPath);
return inner_match.Success;
});
return is_match;
}
private static Dictionary<string, string> GetMapArguments(string realPath, string predictedPath)