diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-05-23 19:37:31 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-23 19:37:31 -0500 |
| commit | 746f7ceefa61e62ad801b825f80b87fe9c853c44 (patch) | |
| tree | 52afa6e3ee234950bbd338e3d086b682da277b58 /src/slskd/Common/Validation/AbsolutePathAttribute.cs | |
| parent | 0bc3f2e327d8ae9a8a0bd1058cb90c59c58933ee (diff) | |
| parent | 8870f4f5590373d54370e64c7b9081521245d8dc (diff) | |
| download | slskd-746f7ceefa61e62ad801b825f80b87fe9c853c44.tar.gz | |
Merge pull request #1740 from slskd/paths
Change path manipulation logic (again)
Diffstat (limited to 'src/slskd/Common/Validation/AbsolutePathAttribute.cs')
| -rw-r--r-- | src/slskd/Common/Validation/AbsolutePathAttribute.cs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/slskd/Common/Validation/AbsolutePathAttribute.cs b/src/slskd/Common/Validation/AbsolutePathAttribute.cs index 1999220f..eb1c9069 100644 --- a/src/slskd/Common/Validation/AbsolutePathAttribute.cs +++ b/src/slskd/Common/Validation/AbsolutePathAttribute.cs @@ -33,19 +33,31 @@ namespace slskd.Validation { using System.ComponentModel.DataAnnotations; + using System.Runtime.InteropServices; /// <summary> /// Validates that the specified path is absolute. /// </summary> public class AbsolutePathAttribute : ValidationAttribute { + public AbsolutePathAttribute() + { + } + + public AbsolutePathAttribute(OSPlatform? os = null) + { + OS = os; + } + + public OSPlatform? OS { get; } + protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (value != null && value is string str && !string.IsNullOrEmpty(str)) { var path = value.ToString(); - if (!FileSafety.IsPathAbsolute(path)) + if (!FileSafety.IsPathAbsolute(path, os: OS)) { return new ValidationResult($"The {validationContext.DisplayName} field must be an absolute file path."); } |
