From f89ea9e2ff1b14e44478f6561e31df31ece17ca8 Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Wed, 23 Oct 2024 07:44:00 -0700 Subject: [PATCH] feat(filters): sanitize description (#1781) feat(filters): sanitize description --- internal/domain/filter.go | 5 +++++ internal/domain/filter_test.go | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/internal/domain/filter.go b/internal/domain/filter.go index 2755da8..1d75c97 100644 --- a/internal/domain/filter.go +++ b/internal/domain/filter.go @@ -332,6 +332,11 @@ func (f *Filter) Sanitize() error { f.ExceptReleases = sanitize.FilterString(f.ExceptReleases) } + if !f.UseRegexDescription { + f.MatchDescription = sanitize.FilterString(f.MatchDescription) + f.ExceptDescription = sanitize.FilterString(f.ExceptDescription) + } + f.MatchReleaseGroups = sanitize.FilterString(f.MatchReleaseGroups) f.ExceptReleaseGroups = sanitize.FilterString(f.ExceptReleaseGroups) diff --git a/internal/domain/filter_test.go b/internal/domain/filter_test.go index eda4004..d978a15 100644 --- a/internal/domain/filter_test.go +++ b/internal/domain/filter_test.go @@ -1966,6 +1966,15 @@ func TestFilter_CheckFilter1(t *testing.T) { rejectionReasons: &RejectionReasons{data: []Rejection{}}, wantMatch: true, }, + { + name: "test_44", + fields: fields{ + MatchDescription: "*black?metal*", + }, + args: args{&Release{Description: "dog\ncat\r\nblack metalo\negg"}}, + rejectionReasons: &RejectionReasons{data: []Rejection{}}, + wantMatch: true, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -1989,6 +1998,9 @@ func TestFilter_CheckFilter1(t *testing.T) { MatchReleaseTags: tt.fields.MatchReleaseTags, ExceptReleaseTags: tt.fields.ExceptReleaseTags, UseRegexReleaseTags: tt.fields.UseRegexReleaseTags, + MatchDescription: tt.fields.MatchDescription, + ExceptDescription: tt.fields.ExceptDescription, + UseRegexDescription: tt.fields.UseRegexDescription, Scene: tt.fields.Scene, Origins: tt.fields.Origins, ExceptOrigins: tt.fields.ExceptOrigins,