Skip to content

Commit 6b99933

Browse files
bracketed comments
1 parent d1649a9 commit 6b99933

7 files changed

Lines changed: 22 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ FEATURES
1818

1919
- Supports all of the base Sieve spec from RFC 5228, except for
2020
features still listed under TODO below
21-
- multiline strings (since version 0.2.2)
21+
- multiline strings (since version 0.2.2)
22+
- bracketed comments (since version 0.2.4)
2223
- Extensions supported:
2324
- regex (draft-ietf-sieve-regex-01)
2425
- body (RFC 5173)
@@ -72,7 +73,6 @@ TODO
7273
- Base spec features not yet implemented:
7374
- encoded characters (section 2.4.2.4)
7475
- multi-line strings (section 2.4.2)
75-
- bracketed comments (section 2.3)
7676
- message uniqueness (section 2.10.3)
7777
- envelope test (section 5.4)
7878
- handle message loops (section 10)

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ FEATURES
1111
features still listed under TODO below
1212

1313
- multiline strings (since version 0.2.2)
14+
- bracketed comments (since version 0.2.4)
1415

1516
- Extensions supported:
1617

@@ -76,7 +77,6 @@ TODO
7677
- Base spec features not yet implemented:
7778

7879
- encoded characters (section 2.4.2.4)
79-
- bracketed comments (section 2.3)
8080
- message uniqueness (section 2.10.3)
8181
- envelope test (section 5.4)
8282
- handle message loops (section 10)

sifter/grammar/lexer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ def t_HASH_COMMENT(self, t: 'LexToken') -> Optional['LexToken']:
4747

4848
# section 2.3
4949
def t_BRACKET_COMMENT(self, t: 'LexToken') -> Optional['LexToken']:
50-
r'/\*.*\*/'
51-
# TODO: Bracketed comments begin with the token "/*" and end with "*/"
50+
r'/\*[\r\n\S\s.]*?\*/'
51+
# Bracketed comments begin with the token "/*" and end with "*/"
5252
# outside of a string. Bracketed comments may span multiple lines.
5353
# Bracketed comments do not nest.
5454
return None
5555

5656
# section 2.4.2
5757
def t_MULTILINE_STRING(self, t: 'LexToken') -> Optional['LexToken']:
5858
r'text:\s?(?:\#.*)\r?\n(?P<multilinetext>[\r\n\S\s.]*?\r?\n)\.\r?\n'
59-
# TODO: For entering larger amounts of text, such as an email message,
59+
# For entering larger amounts of text, such as an email message,
6060
# a multi-line form is allowed. It starts with the keyword "text:",
6161
# followed by a CRLF, and ends with the sequence of a CRLF, a single
6262
# period, and another CRLF. The CRLF before the final period is

tests/evaluation_4.rules

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ require "reject";
22

33
if header "from" "coyote@desert.example.org"
44
{
5-
reject "I do not accept messages from this address."
6-
;
5+
reject "I do not accept messages from this address.";
76
}

tests/evaluation_5.rules

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
require "reject";
22

3-
if header "from" "coyote@desert.example.org"
3+
#testcomment1
4+
5+
if header "from" "coyote@desert.example.org" # testcomment2
46
{
5-
reject text: # testcomment
7+
reject text: # testcomment3
68
I do not accept messages from
79
this address.
810
..

tests/evaluation_6.rules

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require "reject";
2+
3+
if header "from" "coyote@desert.example.org" /*
4+
This is a comment
5+
{
6+
reject "not evaluated, because comment.";
7+
}
8+
*/{
9+
reject "I do not accept messages from this address.";
10+
}

tests/test_evaluation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def test_evaulation():
2626
("evaluation_3.msg", "evaluation_3.rules", [('keep', None)]),
2727
("evaluation_1.msg", "evaluation_4.rules", [('reject', 'I do not accept messages from this address.')]),
2828
("evaluation_1.msg", "evaluation_5.rules", [('reject', 'I do not accept messages from\nthis address.\n.\n')]),
29+
("evaluation_1.msg", "evaluation_6.rules", [('reject', 'I do not accept messages from this address.')]),
2930
)
3031

3132
for messagefile, rulefile, evaluated_rules in EVAL_RESULTS:

0 commit comments

Comments
 (0)