mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 19:47:21 +01:00
fix validation
This commit is contained in:
parent
f229edd510
commit
29c4df1e71
1 changed files with 5 additions and 4 deletions
|
|
@ -125,11 +125,12 @@ public partial class MareHub
|
|||
|
||||
foreach (var replacement in characterCache.FileReplacements.SelectMany(p => p.Value))
|
||||
{
|
||||
if (replacement.GamePaths.Any(p => !GamePathRegex().IsMatch(p))
|
||||
|| (!string.IsNullOrEmpty(replacement.Hash) && !HashRegex().IsMatch(replacement.Hash))
|
||||
|| (!string.IsNullOrEmpty(replacement.FileSwapPath) && !GamePathRegex().IsMatch(replacement.FileSwapPath)))
|
||||
bool validGamePaths = replacement.GamePaths.All(p => GamePathRegex().IsMatch(p));
|
||||
bool validHash = string.IsNullOrEmpty(replacement.Hash) || HashRegex().IsMatch(replacement.Hash);
|
||||
bool validFileSwapPath = string.IsNullOrEmpty(replacement.FileSwapPath) || GamePathRegex().IsMatch(replacement.FileSwapPath);
|
||||
if (!validGamePaths || !validHash || !validFileSwapPath)
|
||||
{
|
||||
_logger.LogCallWarning(MareHubLogger.Args("Invalid Data"));
|
||||
_logger.LogCallWarning(MareHubLogger.Args("Invalid Data", "GamePaths", validGamePaths, "Hash", validHash, "FileSwap", validFileSwapPath));
|
||||
throw new HubException("Invalid data provided");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue