diff --git a/frontend/src/Components/Form/TextTagInputConnector.js b/frontend/src/Components/Form/TextTagInputConnector.js index 17677a51e..be5abb16e 100644 --- a/frontend/src/Components/Form/TextTagInputConnector.js +++ b/frontend/src/Components/Form/TextTagInputConnector.js @@ -49,7 +49,11 @@ class TextTagInputConnector extends Component { const newTags = tag.name.startsWith('/') ? [tag.name] : split(tag.name); newTags.forEach((newTag) => { - newValue.push(newTag.trim()); + const newTagValue = newTag.trim(); + + if (newTagValue) { + newValue.push(newTagValue); + } }); onChange({ name, value: newValue }); @@ -80,7 +84,12 @@ class TextTagInputConnector extends Component { const newValue = [...valueArray]; newValue.splice(tagToReplace.index, 1); - newValue.push(newTag.name.trim()); + + const newTagValue = newTag.name.trim(); + + if (newTagValue) { + newValue.push(newTagValue); + } onChange({ name, value: newValue }); }; diff --git a/src/Radarr.Api.V3/Profiles/Release/ReleaseProfileController.cs b/src/Radarr.Api.V3/Profiles/Release/ReleaseProfileController.cs index 6a54fe620..72aa81201 100644 --- a/src/Radarr.Api.V3/Profiles/Release/ReleaseProfileController.cs +++ b/src/Radarr.Api.V3/Profiles/Release/ReleaseProfileController.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using FluentValidation; using Microsoft.AspNetCore.Mvc; using NzbDrone.Common.Extensions; @@ -23,9 +24,19 @@ public ReleaseProfileController(IReleaseProfileService profileService, IIndexerF SharedValidator.RuleFor(d => d).Custom((restriction, context) => { - if (restriction.MapIgnored().Empty() && restriction.MapRequired().Empty()) + if (restriction.MapRequired().Empty() && restriction.MapIgnored().Empty()) { - context.AddFailure("'Must contain' or 'Must not contain' is required"); + context.AddFailure(nameof(ReleaseProfile.Required), "'Must contain' or 'Must not contain' is required"); + } + + if (restriction.MapRequired().Any(t => t.IsNullOrWhiteSpace())) + { + context.AddFailure(nameof(ReleaseProfile.Required), "'Must contain' should not contain whitespaces or an empty string"); + } + + if (restriction.MapIgnored().Any(t => t.IsNullOrWhiteSpace())) + { + context.AddFailure(nameof(ReleaseProfile.Ignored), "'Must not contain' should not contain whitespaces or an empty string"); } if (restriction.Enabled && restriction.IndexerId != 0 && !_indexerFactory.Exists(restriction.IndexerId)) diff --git a/src/Radarr.Api.V3/Profiles/Release/ReleaseProfileResource.cs b/src/Radarr.Api.V3/Profiles/Release/ReleaseProfileResource.cs index beb10323f..54b49ba73 100644 --- a/src/Radarr.Api.V3/Profiles/Release/ReleaseProfileResource.cs +++ b/src/Radarr.Api.V3/Profiles/Release/ReleaseProfileResource.cs @@ -88,18 +88,18 @@ private static List ParseArray(object resource, string title) { if (array.ValueKind == JsonValueKind.String) { - return array.GetString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); + return array.GetString().Split(new[] { ',' }, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries).ToList(); } if (array.ValueKind == JsonValueKind.Array) { - return JsonSerializer.Deserialize>(array); + return array.Deserialize>(); } } if (resource is string str) { - return str.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); + return str.Split(new[] { ',' }, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries).ToList(); } throw new BadRequestException($"Invalid field {title}, should be string or string array");