From: Philip Hazel Date: Fri, 7 Jul 2006 14:36:04 +0000 (+0000) Subject: Diagnose an error for "seen", "unseen", or "noerror" if not followed by X-Git-Tag: exim-4_63~20 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=41609df58fdd3fe023b91baece7d18a595f57e56;p=exim.git Diagnose an error for "seen", "unseen", or "noerror" if not followed by a command. --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 2ab45d798..90a8a8350 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.371 2006/07/07 13:54:32 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.372 2006/07/07 14:36:04 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -86,6 +86,9 @@ PH/13 If write_rejectlog was set false when logging was sent to syslog with PH/14 In the default configuration, change the use of "message" in ACL warn statements to "add_header". +PH/15 Diagnose a filter syntax error for "seen", "unseen", or "noerror" if not + not followed by a command (e.g. "seen endif"). + Exim version 4.62 ----------------- diff --git a/src/src/filter.c b/src/src/filter.c index a924defa2..b149620e1 100644 --- a/src/src/filter.c +++ b/src/src/filter.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/filter.c,v 1.10 2006/06/27 14:34:26 ph10 Exp $ */ +/* $Cambridge: exim/src/src/filter.c,v 1.11 2006/07/07 14:36:04 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -1044,6 +1044,13 @@ switch (command) case elif_command: case else_command: case endif_command: + if (seen_force || noerror_force) + { + *error_pointer = string_sprintf("\"seen\", \"unseen\", or \"noerror\" " + "near line %d is not followed by a command", line_number); + yield = FALSE; + } + if (expect_endif > 0) had_else_endif = (command == elif_command)? had_elif : (command == else_command)? had_else : had_endif; @@ -1316,6 +1323,12 @@ switch (command) case seen_command: case unseen_command: + if (*ptr == 0) + { + *error_pointer = string_sprintf("\"seen\" or \"unseen\" " + "near line %d is not followed by a command", line_number); + yield = FALSE; + } if (seen_force) { *error_pointer = string_sprintf("\"seen\" or \"unseen\" repeated " @@ -1331,6 +1344,12 @@ switch (command) /* So does noerror */ case noerror_command: + if (*ptr == 0) + { + *error_pointer = string_sprintf("\"noerror\" " + "near line %d is not followed by a command", line_number); + yield = FALSE; + } noerror_force = TRUE; was_noerror = TRUE; break; diff --git a/test/aux-fixed/0037.f-8 b/test/aux-fixed/0037.f-8 new file mode 100644 index 000000000..2807c12f0 --- /dev/null +++ b/test/aux-fixed/0037.f-8 @@ -0,0 +1,5 @@ +#exim filter + +if one is one then seen endif + +if two is two then save /dev/null endif diff --git a/test/aux-fixed/0037.f-9 b/test/aux-fixed/0037.f-9 new file mode 100644 index 000000000..5d8e0ca24 --- /dev/null +++ b/test/aux-fixed/0037.f-9 @@ -0,0 +1,3 @@ +#exim filter + +unseen diff --git a/test/scripts/0000-Basic/0037 b/test/scripts/0000-Basic/0037 index 5737c724b..a1af00d6e 100644 --- a/test/scripts/0000-Basic/0037 +++ b/test/scripts/0000-Basic/0037 @@ -177,4 +177,12 @@ exim -bt prepend@test.ex # Check not prepend $home exim -DFILTER_PREPEND_HOME=no_filter_prepend_home -bt prepend@test.ex **** +# Check error for (un)seen and no command +1 +exim -bf DIR/aux-fixed/TESTNUM.f-8 /usr/relative transport = appendfile prepend@test.ex -> relative transport = appendfile +Warning: no message headers read +Return-path copied from sender +Sender = CALLER@test.ex +Recipient = CALLER@test.ex +Testing Exim filter file "TESTSUITE/aux-fixed/0037.f-8" + +Filter error: "seen", "unseen", or "noerror" near line 5 is not followed by a command +Warning: no message headers read +Return-path copied from sender +Sender = CALLER@test.ex +Recipient = CALLER@test.ex +Testing Exim filter file "TESTSUITE/aux-fixed/0037.f-9" + +Filter error: "seen" or "unseen" near line 4 is not followed by a command