From d62eea604ad6f7e80b30f05a1b7ddac29fde6481 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 8 Apr 2025 02:43:58 +0300 Subject: [PATCH] Validation for tags label --- src/Sonarr.Api.V3/Tags/TagController.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Sonarr.Api.V3/Tags/TagController.cs b/src/Sonarr.Api.V3/Tags/TagController.cs index c4880657b..3c8bdb783 100644 --- a/src/Sonarr.Api.V3/Tags/TagController.cs +++ b/src/Sonarr.Api.V3/Tags/TagController.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using System.Text.RegularExpressions; +using FluentValidation; using Microsoft.AspNetCore.Mvc; using NzbDrone.Core.AutoTagging; using NzbDrone.Core.Datastore.Events; @@ -23,6 +25,11 @@ public TagController(IBroadcastSignalRMessage signalRBroadcaster, : base(signalRBroadcaster) { _tagService = tagService; + + SharedValidator.RuleFor(c => c.Label).Cascade(CascadeMode.Stop) + .NotEmpty() + .Matches("^[a-z0-9-]+$", RegexOptions.IgnoreCase) + .WithMessage("Allowed characters a-z, 0-9 and -"); } protected override TagResource GetResourceById(int id)