[Filter] Add safeguard case for exact matches

This commit is contained in:
Matt Nadareski
2017-02-08 20:56:32 -08:00
parent e8bcad896e
commit 7bb64d81a5

View File

@@ -476,8 +476,16 @@ namespace SabreTools.Helper.Dats
{ {
if (!String.IsNullOrEmpty(straw)) if (!String.IsNullOrEmpty(straw))
{ {
string regexStraw = straw;
// If the straw has no special characters at all, treat it as an exact match
if (regexStraw == Regex.Escape(regexStraw))
{
regexStraw = "^" + regexStraw + "$";
}
// Check if a match is found with the regex // Check if a match is found with the regex
found |= Regex.IsMatch(needle, straw, RegexOptions.IgnoreCase); found |= Regex.IsMatch(needle, regexStraw, RegexOptions.IgnoreCase);
} }
} }