From 37fc124b0851c8e633dea10ac806a2a29fabb0cc Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Fri, 10 Jan 2025 07:04:57 +0100 Subject: [PATCH] [backend/core] Fix negated search parameters when match:words is used --- .../Core/Extensions/QueryableFtsExtensions.cs | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Iceshrimp.Backend/Core/Extensions/QueryableFtsExtensions.cs b/Iceshrimp.Backend/Core/Extensions/QueryableFtsExtensions.cs index cc182af9..cb3bded3 100644 --- a/Iceshrimp.Backend/Core/Extensions/QueryableFtsExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/QueryableFtsExtensions.cs @@ -274,34 +274,34 @@ public static class QueryableFtsExtensions ) => matchType.Equals(MatchFilterType.Substring) ? caseSensitivity.Equals(CaseFilterType.Sensitive) ? negated - ? !EF.Functions.Like(note.Text!, "%" + query + "%", @"\") - && !EF.Functions.Like(note.Cw!, "%" + query + "%", @"\") - && !EF.Functions.Like(note.CombinedAltText!, "%" + query + "%", @"\") - : EF.Functions.Like(note.Text!, "%" + query + "%", @"\") - || EF.Functions.Like(note.Cw!, "%" + query + "%", @"\") - || EF.Functions.Like(note.CombinedAltText!, "%" + query + "%", @"\") + ? !EF.Functions.Like(note.Text ?? "", "%" + query + "%", @"\") + && !EF.Functions.Like(note.Cw ?? "", "%" + query + "%", @"\") + && !EF.Functions.Like(note.CombinedAltText ?? "", "%" + query + "%", @"\") + : EF.Functions.Like(note.Text ?? "", "%" + query + "%", @"\") + || EF.Functions.Like(note.Cw ?? "", "%" + query + "%", @"\") + || EF.Functions.Like(note.CombinedAltText ?? "", "%" + query + "%", @"\") : negated - ? !EF.Functions.ILike(note.Text!, "%" + query + "%", @"\") - && !EF.Functions.ILike(note.Cw!, "%" + query + "%", @"\") - && !EF.Functions.ILike(note.CombinedAltText!, "%" + query + "%", @"\") - : EF.Functions.ILike(note.Text!, "%" + query + "%", @"\") - || EF.Functions.ILike(note.Cw!, "%" + query + "%", @"\") - || EF.Functions.ILike(note.CombinedAltText!, "%" + query + "%", @"\") + ? !EF.Functions.ILike(note.Text ?? "", "%" + query + "%", @"\") + && !EF.Functions.ILike(note.Cw ?? "", "%" + query + "%", @"\") + && !EF.Functions.ILike(note.CombinedAltText ?? "", "%" + query + "%", @"\") + : EF.Functions.ILike(note.Text ?? "", "%" + query + "%", @"\") + || EF.Functions.ILike(note.Cw ?? "", "%" + query + "%", @"\") + || EF.Functions.ILike(note.CombinedAltText ?? "", "%" + query + "%", @"\") : caseSensitivity.Equals(CaseFilterType.Sensitive) ? negated - ? !Regex.IsMatch(note.Text!, "\\y" + query + "\\y") - && !Regex.IsMatch(note.Cw!, "\\y" + query + "\\y") - && !Regex.IsMatch(note.CombinedAltText!, "\\y" + query + "\\y") - : Regex.IsMatch(note.Text!, "\\y" + query + "\\y") - || Regex.IsMatch(note.Cw!, "\\y" + query + "\\y") - || Regex.IsMatch(note.CombinedAltText!, "\\y" + query + "\\y") + ? !Regex.IsMatch(note.Text ?? "", "\\y" + query + "\\y") + && !Regex.IsMatch(note.Cw ?? "", "\\y" + query + "\\y") + && !Regex.IsMatch(note.CombinedAltText ?? "", "\\y" + query + "\\y") + : Regex.IsMatch(note.Text ?? "", "\\y" + query + "\\y") + || Regex.IsMatch(note.Cw ?? "", "\\y" + query + "\\y") + || Regex.IsMatch(note.CombinedAltText ?? "", "\\y" + query + "\\y") : negated - ? !Regex.IsMatch(note.Text!, "\\y" + query + "\\y", RegexOptions.IgnoreCase) - && !Regex.IsMatch(note.Cw!, "\\y" + query + "\\y", RegexOptions.IgnoreCase) - && !Regex.IsMatch(note.CombinedAltText!, "\\y" + query + "\\y", RegexOptions.IgnoreCase) - : Regex.IsMatch(note.Text!, "\\y" + query + "\\y", RegexOptions.IgnoreCase) - || Regex.IsMatch(note.Cw!, "\\y" + query + "\\y", RegexOptions.IgnoreCase) - || Regex.IsMatch(note.CombinedAltText!, "\\y" + query + "\\y", RegexOptions.IgnoreCase); + ? !Regex.IsMatch(note.Text ?? "", "\\y" + query + "\\y", RegexOptions.IgnoreCase) + && !Regex.IsMatch(note.Cw ?? "", "\\y" + query + "\\y", RegexOptions.IgnoreCase) + && !Regex.IsMatch(note.CombinedAltText ?? "", "\\y" + query + "\\y", RegexOptions.IgnoreCase) + : Regex.IsMatch(note.Text ?? "", "\\y" + query + "\\y", RegexOptions.IgnoreCase) + || Regex.IsMatch(note.Cw ?? "", "\\y" + query + "\\y", RegexOptions.IgnoreCase) + || Regex.IsMatch(note.CombinedAltText ?? "", "\\y" + query + "\\y", RegexOptions.IgnoreCase); [Projectable] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global",