Skip to content

Commit 5123183

Browse files
Merge branch 'develop'
2 parents 918cfd9 + b634471 commit 5123183

File tree

6 files changed

+46
-6
lines changed

6 files changed

+46
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ FEATURES
2626
- variables (RFC 5229)
2727
- enotify (RFC 5435, particularly the mailto method RFC 5436)
2828
- imap4flags (RFC 5232: setflag, addflag, removeflag; not supported: hasflags, :flags)
29-
- compatible with the python 2 version from https://github.com/garyp/sifter
29+
- reject and ereject (RFC 5429)
30+
- ihave (RFC 5463)
31+
3032

3133
INSTALL
3234
=======
@@ -72,7 +74,6 @@ TODO
7274
filtering
7375
- Base spec features not yet implemented:
7476
- encoded characters (section 2.4.2.4)
75-
- multi-line strings (section 2.4.2)
7677
- message uniqueness (section 2.10.3)
7778
- envelope test (section 5.4)
7879
- handle message loops (section 10)
@@ -94,6 +95,5 @@ TODO
9495
- environment (RFC 5183)
9596
- date and index (RFC 5260)
9697
- editheader (RFC 5293)
97-
- ihave (RFC 5463)
9898
- mailbox metadata (RFC 5490)
9999
- xmpp notifications (RFC 5437)

docs/index.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ FEATURES
2020
- variables (RFC 5229)
2121
- enotify (RFC 5435, particularly the mailto method RFC 5436)
2222
- imap4flags (RFC 5232: setflag, addflag, removeflag; not supported: hasflags, :flags)
23-
24-
- compatible with the Python 2 version from https://github.com/garyp/sifter
23+
- reject and ereject (RFC 5429) (since version 0.2.4)
24+
- ihave (RFC 5463) (since version 0.2.5)
2525

2626
INSTALL
2727
-------
@@ -81,3 +81,5 @@ TODO
8181
- envelope test (section 5.4)
8282
- handle message loops (section 10)
8383
- limit abuse of redirect action (section
84+
- address test should limit allowed headers to those that contain
85+
addresses (section 5.1)

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name="sifter3",
13-
version="0.2.4",
13+
version="0.2.5",
1414
author="Manfred Kaiser, Gary Peck",
1515
author_email="manfred.kaiser@logfile.at, gary@realify.com",
1616
url="https://sifter3.readthedocs.io/en/latest/",
@@ -78,6 +78,7 @@
7878
'true = sifter.tests.true:TestTrue',
7979
'valid_notify_method = sifter.tests.notify:TestValidNotifyMethod',
8080
'notify_method_capability = sifter.tests.notify:TestValidNotifyMethod',
81+
'ihave = sifter.tests.ihave:TestIHave',
8182
# sifter comparators
8283
'ascii_casemap = sifter.comparators.ascii_casemap:ComparatorASCIICasemap',
8384
'ascii_casemap_noi = sifter.comparators.ascii_casemap:ComparatorASCIICasemapnoi',

sifter/tests/ihave.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from email.message import Message
2+
from typing import (
3+
Optional
4+
)
5+
from sifter.grammar.state import EvaluationState
6+
from sifter.extensions import ExtensionRegistry
7+
8+
from sifter.grammar.test import Test
9+
from sifter.validators.stringlist import StringList
10+
11+
12+
# RFC 5463
13+
class TestIHave(Test):
14+
15+
HANDLER_ID = 'IHAVE'
16+
EXTENSION_NAME = 'ihave'
17+
POSITIONAL_ARGS = [
18+
StringList(),
19+
]
20+
21+
def evaluate(self, message: Message, state: EvaluationState) -> Optional[bool]:
22+
state.check_required_extension('ihave', 'conditions on installed extensions')
23+
extension_list = self.positional_args[0]
24+
25+
ret_val = True
26+
for ext_name in extension_list: # type: ignore
27+
if ExtensionRegistry.has_extension(ext_name):
28+
state.require_extension(ext_name)
29+
else:
30+
ret_val = False
31+
return ret_val
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require "ihave";
2+
3+
if ihave "reject"{
4+
reject "I do not accept messages from this address.";
5+
}

tests/test_evaluation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def test_evaulation():
2828
("evaluation_1.msg", "evaluation_5.rules", [('reject', 'I do not accept messages from\nthis address.\n.\n')]),
2929
("evaluation_1.msg", "evaluation_6.rules", [('reject', 'I do not accept messages from this address.')]),
3030
("evaluation_1.msg", "evaluation_7.rules", [('reject', 'I do not accept messages from/* this is\nnot a comment */this address.\n.\n')]),
31+
("evaluation_1.msg", "evaluation_ihave_reject.rules", [('reject', 'I do not accept messages from this address.')]),
3132
)
3233

3334
for messagefile, rulefile, evaluated_rules in EVAL_RESULTS:

0 commit comments

Comments
 (0)