Bug 4648 - [review] Illegal declaration of anonymous subroutine - Rules starting with digits
Summary: [review] Illegal declaration of anonymous subroutine - Rules starting with di...
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Rules (show other bugs)
Version: 3.1.0
Hardware: All other
: P5 enhancement
Target Milestone: 3.1.1
Assignee: Daryl C. W. O'Shea
URL:
Whiteboard: ready to commit
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-26 17:32 UTC by Fred T
Modified: 2005-12-08 18:27 UTC (History)
1 user (show)



Attachment Type Modified Status Actions Submitter/CLA Status
patch patch None Daryl C. W. O'Shea [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Fred T 2005-10-26 17:32:25 UTC
Custom rule writing is becoming more and more popular.  We ran into an issue 
today with a rule starting with a number causing a lint failure in an unrelated 
file.

To see this yourself, create a new .cf file and add a test rule whose name 
starts with a number.  Run lint on this rule and it will produce something like:

[500] warn: rules: failed to compile body tests, skipping:
[500] warn: _(Illegal declaration of anonymous subroutine at C:\Perl\Site\Share\
SpamAssassin/20_drugs.cf, rule __DRUGS_DIET7, line 10.
[500] warn: )

On different systems the error message varies:
(Illegal declaration of anonymous subroutine at (no file), rule RADAR, line 10.)

And another system gave us:
[23637] warn: _(Illegal declaration of anonymous subroutine at
/etc/mail/spamassassin/70_sare_oem.cf, rule __OEM_MS_9, line 10.
[23637] warn: )



20_drugs.cf has nothing to do with this lint error, the file at fault was named 
00_test.cf

The error message produced by lint also makes it somewhat difficult to track 
down what is causing this problem.  I'm asking if lint could be enhanced to 
catch this better?

I have read someplace (possibly docs) that rules can not start with a number, 
I'm not asking for that to change, just that it be more clear when this does 
happen why it's happening.

Thank you!
Frederic Tarasevicius
Comment 1 Bob Menschel 2005-10-29 08:28:13 UTC
Triage: Not knowing much about the --lint process, IMO it should be easy to add
a quick check "if any rule begins with a digit, report this as a --lint error
and disable that rule from further checking". I'm assigning a target milestone
hoping I'm right. No problem if this has to get shifted to 3.2.0. 
Comment 2 Justin Mason 2005-10-29 22:22:37 UTC
hi Fred, Bob, yep -- agreed.

not a major issue, though, since at least the documentation is explicit about
this being a bad idea ;)
Comment 3 Daryl C. W. O'Shea 2005-11-01 01:00:18 UTC
Created attachment 3222 [details]
patch

Fixes rule name check and also checks for rule names that cause subroutine
identifiers to be too long.
Comment 4 Daryl C. W. O'Shea 2005-11-04 04:05:16 UTC
trunk revision 330694
Comment 5 Justin Mason 2005-11-18 06:54:22 UTC
+1
Comment 6 Justin Mason 2005-12-08 22:21:33 UTC
ping: 1 vote needed
Comment 7 Duncan Findlay 2005-12-09 03:22:48 UTC
+1
Comment 8 Daryl C. W. O'Shea 2005-12-09 03:27:06 UTC
3.1: Committed revision 355322.