Skip to content

Commit

Permalink
Remove bad code. Caused false negatives if customRegex was null, but the
Browse files Browse the repository at this point in the history
filter itself was not.
  • Loading branch information
Kinematics committed Nov 22, 2016
1 parent cd5b733 commit 71d1598
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions TallyCore/Filters/BaseFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,15 @@ protected static Regex CreateCustomRegex(string customFilterString, bool allowBl
/// the custom filter regex.
/// </summary>
/// <param name="test">The string to test.</param>
/// <returns>Returns true if the provided string matches the currently active filter.
/// If the test string is null or empty, will always return false.
/// If there is no currently active filter, and test has some value, will always return true.</returns>
/// <returns>
/// Returns true if the provided string matches the current (or default) filter.
/// Always returns false if the test string is null.
/// If the custom and default filters are null, returns true.</returns>
public bool Filter(string test)
{
// Test string should never be null. If it is, return false.
if (test == null)
{
return false;
}

if (string.IsNullOrEmpty(test))
{
return (customRegex != null && customRegex.ToString() == emptyLine);
}

return customRegex?.Match(test).Success ?? defaultRegex?.Match(test).Success ?? true;
}
Expand Down

0 comments on commit 71d1598

Please sign in to comment.