You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by MySQL Student <my...@gmail.com> on 2009/06/19 00:01:32 UTC

Debugging and scripting

Hi. I'm relatively new to spamassassin and perl scripting, and I must
already be doing a few things wrong that I hoped the list could help me to
solve. I'm receiving the following output when running "spamassassin -D <
spam-test.txt 2>&1|less'

[32692] warn: Number found where operator expected at (eval 607) line 1,
near "0  0"
[32692] warn:  (Missing operator before 0?)

Where is this coming from? Perhaps local.cf, but where? It's not line 607.

I'm also having a problem with one of my rules:

[32692] info: config: invalid expression for rule LOCAL_XPS: "Subject =~
/Free\ DELL\ XPS/i": syntax error

Here is the full rule:

meta       LOCAL_XPS            Subject =~ /Free\ DELL\ XPS/i
score      LOCAL_XPS            1.5
describe   LOCAL_XPS            Rule by AS: XPS Dell

Do I need the backslashes to escape the spaces? Will that match that pattern
anywhere on the line, or only
that text on the line?

Can you explain to me the meaning of '(.+)' as in:

header LOCAL_RULE1      Subject =~ /(.+)Spam\ Sample(.+)/i
score LOCAL_RULE1       5.0
describe LOCAL_RULE1    Subject Spam Sample

How about without the parens?

I believe this is somehow causing emails to hit the "MISSING_SUBJECT" rule,
even though the email clearly
has a subject.

Any help greatly appreciated.
Thanks,
Alex

Re: Debugging and scripting

Posted by Evan Platt <ev...@espphotography.com>.
At 03:01 PM 6/18/2009, you wrote:
>Hi. I'm relatively new to spamassassin and perl scripting, and I 
>must already be doing a few things wrong that I hoped the list could 
>help me to solve. I'm receiving the following output when running 
>"spamassassin -D < spam-test.txt 2>&1|less'
>
>[32692] warn: Number found where operator expected at (eval 607) 
>line 1, near "0  0"
>[32692] warn:  (Missing operator before 0?)
>
>Where is this coming from? Perhaps <http://local.cf>local.cf, but 
>where? It's not line 607.

Unfortunately, I can't help, but just want to point out - it's line 
1. That may help. :) 


Re: Debugging and scripting

Posted by MySQL Student <my...@gmail.com>.
Hi Matus (and list :-)


> I'm not Dan. This is a mailing list. Meny people read it and many can
> respond your mail.


Yes, thanks, I had responded to him directly and probably didn't need to,
but the reply-to must not be set to the list address?

/spam sample/ will match the test anywhere on line.
> /.spam sample./ will match the text anywhere on line, except the begin and
> the end, since it must be preceded by at least one character.
>
> /(.+)spam sample(.+)/ will match exactly the same, but the match will be
> slower since the (.+) will need to compare all text before/after the "spam
> sample" and store them both to capture buffers.


Okay, that's great. Thanks so much for your help.

Best regards,
Alex

Re: Debugging and scripting

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
On 18.06.09 19:14, MySQL Student wrote:
> Hi Dan,

I'm not Dan. This is a mailing list. Meny people read it and many can
respond your mail.

> > Do I need the backslashes to escape the spaces?
> >
> > no, although \s would be fine.

> Okay, so either \s or nothing at all works just the same?

the \s works like whitespace character - space, tab. replacing spaces for \s
is OK, unless you want tabs not to match.

> > this can be much more effectively written as:
> > /.spam\ssample./i
> 
> > That will match the words "spam sample" in the subject as long as there
> > is at least 1 character before and one after.
> 
> But you had previously written that /Spam Sample/ will also match that text
> anywhere on the line. Is that not the case?

/spam sample/ will match the test anywhere on line.
/.spam sample./ will match the text anywhere on line, except the begin and
the end, since it must be preceded by at least one character.
 
/(.+)spam sample(.+)/ will match exactly the same, but the match will be
slower since the (.+) will need to compare all text before/after the "spam
sample" and store them both to capture buffers.

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Quantum mechanics: The dreams stuff is made of. 

Re: Debugging and scripting

Posted by MySQL Student <my...@gmail.com>.
Hi Dan,

> Do I need the backslashes to escape the spaces?
>
> no, although \s would be fine.
>

Okay, so either \s or nothing at all works just the same?


> this can be much more effectively written as:
> /.spam\ssample./i


> That will match the words "spam sample" in the subject as long as there
> is at least 1 character before and one after.


But you had previously written that /Spam Sample/ will also match that text
anywhere on the line. Is that not the case?

Thanks again,
Alex

Re: Debugging and scripting

Posted by "McDonald, Dan" <Da...@austinenergy.com>.
On Thu, 2009-06-18 at 18:01 -0400, MySQL Student wrote:

> I'm also having a problem with one of my rules:
> 
> [32692] info: config: invalid expression for rule LOCAL_XPS: "Subject
> =~ /Free\ DELL\ XPS/i": syntax error
> 
> Here is the full rule:
> 
> meta       LOCAL_XPS            Subject =~ /Free\ DELL\ XPS/i

That's not a meta rule.  It's a header rule.
> score      LOCAL_XPS            1.5
> describe   LOCAL_XPS            Rule by AS: XPS Dell
> 
> Do I need the backslashes to escape the spaces?

no, although \s would be fine.

>  Will that match that pattern anywhere on the line,

yes

>  or only
> that text on the line?
> 
> Can you explain to me the meaning of '(.+)' as in:

You are trying to DOS your system by matching any number of
characters...
> header LOCAL_RULE1      Subject =~ /(.+)Spam\ Sample(.+)/i

this can be much more effectively written as:
/.spam\ssample./i

That will match the words "spam sample" in the subject as long as there
is at least 1 character before and one after. 

> score LOCAL_RULE1       5.0
> describe LOCAL_RULE1    Subject Spam Sample
> 
> How about without the parens?
even better.  You can use parens for alteration.

See perldoc perlretut for more hints on regular expressions.


-- 
Daniel J McDonald, CCIE # 2495, CISSP # 78281, CNX
www.austinenergy.com