Merge pull request #89 from awegg/master

Fix issue with spaces after comma and or filters
This commit is contained in:
Ashish Patel 2020-10-23 00:43:05 +05:30 committed by GitHub
commit cada68a83b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -13,7 +13,7 @@ namespace Sieve.Models
where TFilterTerm : IFilterTerm, new() where TFilterTerm : IFilterTerm, new()
where TSortTerm : ISortTerm, new() where TSortTerm : ISortTerm, new()
{ {
private const string EscapedCommaPattern = @"(?<!($|[^\\])(\\\\)*?\\),"; private const string EscapedCommaPattern = @"(?<!($|[^\\])(\\\\)*?\\),\s*";
[DataMember] [DataMember]
public string Filters { get; set; } public string Filters { get; set; }

View File

@ -370,6 +370,23 @@ namespace SieveUnitTests
Assert.AreEqual(1, resultCount); Assert.AreEqual(1, resultCount);
} }
[TestMethod]
public void CombinedAndOrWithSpaceFilteringWorks()
{
var model = new SieveModel()
{
Filters = "Title==D, (Title|LikeCount)==3",
};
var result = _processor.Apply(model, _posts);
var entry = result.FirstOrDefault();
var resultCount = result.Count();
Assert.IsNotNull(entry);
Assert.AreEqual(1, resultCount);
Assert.AreEqual(3, entry.Id);
}
[TestMethod] [TestMethod]
public void OrValueFilteringWorks() public void OrValueFilteringWorks()
{ {