Skip to content

Commit

Permalink
The SearchBrowser regex are now escaped
Browse files Browse the repository at this point in the history
  • Loading branch information
maforget committed Aug 20, 2024
1 parent 9061674 commit ba7cd41
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ComicRack.Engine/Controls/SearchBrowserControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using cYo.Common.Collections;
using cYo.Common.ComponentModel;
Expand Down Expand Up @@ -665,7 +666,7 @@ private static ComicBookMatcher CreateMatcher(SelectionInfo si)
case 1:
{
//This will match the value even if it has trailing & leading spaces. With multiple values the ListContains already does this internally.
string value = si.MultipleValues ? si.SelectedItems.First() : $"(?<=^)\\s*{si.SelectedItems.First()}\\s*(?=$)";
string value = si.MultipleValues ? si.SelectedItems.First() : $"(?<=^)\\s*{Regex.Escape(si.SelectedItems.First())}\\s*(?=$)";
ComicBookValueMatcher comicBookValueMatcher = ComicBookValueMatcher.Create(si.MatcherType,
si.MultipleValues ? ComicBookStringMatcher.OperatorListContains : ComicBookStringMatcher.OperatorRegex,
value, null);
Expand All @@ -682,7 +683,7 @@ private static ComicBookMatcher CreateMatcher(SelectionInfo si)
si.SelectedItems.ForEach(delegate (string s)
{
//This will match the value even if it has trailing & leading spaces. With multiple values the ListContains already does this internally.
string value = si.MultipleValues ? s : $"(?<=^)\\s*{s}\\s*(?=$)";
string value = si.MultipleValues ? s : $"(?<=^)\\s*{Regex.Escape(s)}\\s*(?=$)";
subSet.Matchers.Add(si.MatcherType,
si.MultipleValues ? ComicBookStringMatcher.OperatorListContains : ComicBookStringMatcher.OperatorRegex,
value, null);
Expand Down

0 comments on commit ba7cd41

Please sign in to comment.