diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-06-04 18:07:07 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-06-04 18:07:07 -0500 |
| commit | 483e37f64def66cecb01a8c471d35e2937178960 (patch) | |
| tree | eec853ed52bef304cc50d1bb0ca17cd3f8484f30 | |
| parent | e5d362836ce8892487864170abdc31fc032989c5 (diff) | |
| download | slskd-483e37f64def66cecb01a8c471d35e2937178960.tar.gz | |
change how property injection impacts path validation
| -rw-r--r-- | src/slskd/Common/Validation/AbsolutePathAttribute.cs | 13 | ||||
| -rw-r--r-- | src/slskd/Common/Validation/RelativePathAttribute.cs | 13 |
2 files changed, 2 insertions, 24 deletions
diff --git a/src/slskd/Common/Validation/AbsolutePathAttribute.cs b/src/slskd/Common/Validation/AbsolutePathAttribute.cs index 9393e524..f2615315 100644 --- a/src/slskd/Common/Validation/AbsolutePathAttribute.cs +++ b/src/slskd/Common/Validation/AbsolutePathAttribute.cs @@ -58,20 +58,9 @@ namespace slskd.Validation { var path = value.ToString(); - // this property can only be set via reflection in a unit test; this is here only to make this testable - if (Injected.HasValue) - { - if (!FileSafety.IsPathAbsolute(path, os: Injected)) - { - return new ValidationResult($"The {validationContext.DisplayName} field must be an absolute path."); - } - - return ValidationResult.Success; - } - if (OS == OperatingSystem.Current) { - if (!FileSafety.IsPathAbsolute(path, os: Compute.OperatingSystem())) + if (!FileSafety.IsPathAbsolute(path, os: Injected ?? Compute.OperatingSystem())) { return new ValidationResult($"The {validationContext.DisplayName} field must be an absolute path on the current operating system."); } diff --git a/src/slskd/Common/Validation/RelativePathAttribute.cs b/src/slskd/Common/Validation/RelativePathAttribute.cs index 1bdbd4fb..f691d4e5 100644 --- a/src/slskd/Common/Validation/RelativePathAttribute.cs +++ b/src/slskd/Common/Validation/RelativePathAttribute.cs @@ -59,20 +59,9 @@ namespace slskd.Validation { var path = value.ToString(); - // this property can only be set via reflection in a unit test; this is here only to make this testable - if (Injected.HasValue) - { - if (!FileSafety.IsPathRelative(path, os: Injected)) - { - return new ValidationResult($"The {validationContext.DisplayName} field must be a relative path on the current operating system."); - } - - return ValidationResult.Success; - } - if (OS == OperatingSystem.Current) { - if (!FileSafety.IsPathRelative(path, os: Compute.OperatingSystem())) + if (!FileSafety.IsPathRelative(path, os: Injected ?? Compute.OperatingSystem())) { return new ValidationResult($"The {validationContext.DisplayName} field must be a relative path on all operating systems."); } |
