mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-05 20:42:19 -07:00
New: Prevent Remote Path Mapping local folder being set to System folder or '/'
(cherry picked from commit 0f904e091702a2ac53771ee3aeb5aafe62688035)
This commit is contained in:
parent
4677a1115a
commit
c83332e58c
1 changed files with 9 additions and 6 deletions
|
@ -28,10 +28,13 @@ namespace Lidarr.Api.V1.RemotePathMappings
|
||||||
.NotEmpty();
|
.NotEmpty();
|
||||||
|
|
||||||
SharedValidator.RuleFor(c => c.LocalPath)
|
SharedValidator.RuleFor(c => c.LocalPath)
|
||||||
.Cascade(CascadeMode.Stop)
|
.Cascade(CascadeMode.Stop)
|
||||||
.IsValidPath()
|
.IsValidPath()
|
||||||
.SetValidator(mappedNetworkDriveValidator)
|
.SetValidator(mappedNetworkDriveValidator)
|
||||||
.SetValidator(pathExistsValidator);
|
.SetValidator(pathExistsValidator)
|
||||||
|
.SetValidator(new SystemFolderValidator())
|
||||||
|
.NotEqual("/")
|
||||||
|
.WithMessage("Cannot be set to '/'");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RemotePathMappingResource GetResourceById(int id)
|
public override RemotePathMappingResource GetResourceById(int id)
|
||||||
|
@ -41,7 +44,7 @@ namespace Lidarr.Api.V1.RemotePathMappings
|
||||||
|
|
||||||
[RestPostById]
|
[RestPostById]
|
||||||
[Consumes("application/json")]
|
[Consumes("application/json")]
|
||||||
public ActionResult<RemotePathMappingResource> CreateMapping(RemotePathMappingResource resource)
|
public ActionResult<RemotePathMappingResource> CreateMapping([FromBody] RemotePathMappingResource resource)
|
||||||
{
|
{
|
||||||
var model = resource.ToModel();
|
var model = resource.ToModel();
|
||||||
|
|
||||||
|
@ -62,7 +65,7 @@ namespace Lidarr.Api.V1.RemotePathMappings
|
||||||
}
|
}
|
||||||
|
|
||||||
[RestPutById]
|
[RestPutById]
|
||||||
public ActionResult<RemotePathMappingResource> UpdateMapping(RemotePathMappingResource resource)
|
public ActionResult<RemotePathMappingResource> UpdateMapping([FromBody] RemotePathMappingResource resource)
|
||||||
{
|
{
|
||||||
var mapping = resource.ToModel();
|
var mapping = resource.ToModel();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue