mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-20 06:08:35 +02:00
Removed wrong space in criteria list
This commit is contained in:
@@ -292,20 +292,21 @@ class IMAPconnector:
|
||||
return f"OR {old} {c}"
|
||||
|
||||
if criterion == "both":
|
||||
criterion = "from_addr, subject"
|
||||
criterions = ""
|
||||
for c in criterion.split(","):
|
||||
if c == "from_addr":
|
||||
key = "FROM"
|
||||
elif c == "subject":
|
||||
key = "SUBJECT"
|
||||
else:
|
||||
continue
|
||||
|
||||
criterions = or_criterion(criterions, f'({key} "{pattern}")')
|
||||
|
||||
criterion = "from_addr,subject"
|
||||
|
||||
if not pattern:
|
||||
criterions = "ALL"
|
||||
else:
|
||||
criterions = ""
|
||||
for c in criterion.split(","):
|
||||
if c == "from_addr":
|
||||
key = "FROM"
|
||||
elif c == "subject":
|
||||
key = "SUBJECT"
|
||||
else:
|
||||
continue
|
||||
criterions = or_criterion(criterions, f'({key} "{pattern}")')
|
||||
|
||||
self.criterions = [bytearray(criterions, "utf8")]
|
||||
|
||||
def messages_count(self, **kwargs) -> int:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"""mailutils tests"""
|
||||
|
||||
import io
|
||||
import unittest
|
||||
|
||||
from modoboa.webmail.lib.imaputils import IMAPconnector
|
||||
@@ -23,7 +22,7 @@ class ImapUtilsTestCase(unittest.TestCase):
|
||||
"""Test with both Criterion and pattern"""
|
||||
self.imap_connector.criterions = []
|
||||
self.imap_connector.parse_search_parameters("both", "bob")
|
||||
result = [bytearray('(FROM "bob") OR (SUBJECT "bob")', "utf8")]
|
||||
result = [bytearray('OR (FROM "bob") (SUBJECT "bob")', "utf8")]
|
||||
self.assertEqual(self.imap_connector.criterions, result)
|
||||
|
||||
def test_criterions_one_criterion_without_pattern(self):
|
||||
@@ -31,4 +30,4 @@ class ImapUtilsTestCase(unittest.TestCase):
|
||||
self.imap_connector.criterions = []
|
||||
self.imap_connector.parse_search_parameters("SEEN", "")
|
||||
result = [bytearray("ALL", "utf8")]
|
||||
self.assertEqual(self.imap_connector.criterions, result)
|
||||
self.assertEqual(self.imap_connector.criterions, result)
|
||||
|
||||
Reference in New Issue
Block a user