mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
New: Don't allow remote path to start with space
(cherry picked from commit 5ba3ff598770fdf9e5a53d490c8bcbdd6a59c4cc)
This commit is contained in:
@@ -96,6 +96,11 @@ namespace NzbDrone.Core.RemotePathMappings
|
|||||||
throw new ArgumentException("Invalid Host");
|
throw new ArgumentException("Invalid Host");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mapping.RemotePath.StartsWith(" "))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Remote Path must not start with a space");
|
||||||
|
}
|
||||||
|
|
||||||
var remotePath = new OsPath(mapping.RemotePath);
|
var remotePath = new OsPath(mapping.RemotePath);
|
||||||
var localPath = new OsPath(mapping.LocalPath);
|
var localPath = new OsPath(mapping.LocalPath);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.RemotePathMappings;
|
using NzbDrone.Core.RemotePathMappings;
|
||||||
|
using NzbDrone.Core.Validation;
|
||||||
using NzbDrone.Core.Validation.Paths;
|
using NzbDrone.Core.Validation.Paths;
|
||||||
using Radarr.Http;
|
using Radarr.Http;
|
||||||
using Radarr.Http.REST;
|
using Radarr.Http.REST;
|
||||||
@@ -21,11 +23,20 @@ namespace Radarr.Api.V3.RemotePathMappings
|
|||||||
_remotePathMappingService = remotePathMappingService;
|
_remotePathMappingService = remotePathMappingService;
|
||||||
|
|
||||||
SharedValidator.RuleFor(c => c.Host)
|
SharedValidator.RuleFor(c => c.Host)
|
||||||
.NotEmpty();
|
.NotEmpty();
|
||||||
|
|
||||||
// We cannot use IsValidPath here, because it's a remote path, possibly other OS.
|
// We cannot use IsValidPath here, because it's a remote path, possibly other OS.
|
||||||
SharedValidator.RuleFor(c => c.RemotePath)
|
SharedValidator.RuleFor(c => c.RemotePath)
|
||||||
.NotEmpty();
|
.NotEmpty();
|
||||||
|
|
||||||
|
SharedValidator.RuleFor(c => c.RemotePath)
|
||||||
|
.Must(remotePath => !remotePath.IsNotNullOrWhiteSpace() && !remotePath.StartsWith(" "))
|
||||||
|
.WithMessage("Remote Path must not start with a space");
|
||||||
|
|
||||||
|
SharedValidator.RuleFor(c => c.RemotePath)
|
||||||
|
.Must(remotePath => !remotePath.IsNotNullOrWhiteSpace() && !remotePath.EndsWith(" "))
|
||||||
|
.WithMessage("Remote Path probably should not end with a space")
|
||||||
|
.AsWarning();
|
||||||
|
|
||||||
SharedValidator.RuleFor(c => c.LocalPath)
|
SharedValidator.RuleFor(c => c.LocalPath)
|
||||||
.Cascade(CascadeMode.Stop)
|
.Cascade(CascadeMode.Stop)
|
||||||
|
|||||||
Reference in New Issue
Block a user