fix validation

This commit is contained in:
rootdarkarchon
2022-11-10 13:32:19 +01:00
parent f229edd510
commit 29c4df1e71

View File

@@ -125,11 +125,12 @@ public partial class MareHub
foreach (var replacement in characterCache.FileReplacements.SelectMany(p => p.Value)) foreach (var replacement in characterCache.FileReplacements.SelectMany(p => p.Value))
{ {
if (replacement.GamePaths.Any(p => !GamePathRegex().IsMatch(p)) bool validGamePaths = replacement.GamePaths.All(p => GamePathRegex().IsMatch(p));
|| (!string.IsNullOrEmpty(replacement.Hash) && !HashRegex().IsMatch(replacement.Hash)) bool validHash = string.IsNullOrEmpty(replacement.Hash) || HashRegex().IsMatch(replacement.Hash);
|| (!string.IsNullOrEmpty(replacement.FileSwapPath) && !GamePathRegex().IsMatch(replacement.FileSwapPath))) 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"); throw new HubException("Invalid data provided");
} }
} }