You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by John Horne <jo...@plymouth.ac.uk> on 2010/05/21 15:40:44 UTC

Problem matching newline in body

Hello,

Can you tell it's Friday afternoon? What should be a simple problem
always seems to become a nightmare on Friday afternoons! :-)

Using SA 3.3.1 I have the following simple rule:

     body   LOCAL_JH     /userid:\s*\n/i

which should look for 'userid:', any number of spaces and then a NL
character (that is, there is nothing following the spaces on the same
line).

If I send a message containing:

    some text<NL>
    userid: <NL>
    some more text

it fails. If I insert a NL before 'some more text', then it works.

I tried using '/userid:\s*$/mi', but that too didn't work.


Can someone show me how to match a newline character in the above rule
please?



John.

-- 
John Horne                   Tel: +44 (0)1752 587287
University of Plymouth, UK   Fax: +44 (0)1752 587001

Re: Problem matching newline in body

Posted by John Horne <jo...@plymouth.ac.uk>.
On Fri, 2010-05-21 at 06:53 -0700, John Hardin wrote:
> On Fri, 21 May 2010, John Horne wrote:
> 
> > Hello,
> >
> > Can you tell it's Friday afternoon? What should be a simple problem
> > always seems to become a nightmare on Friday afternoons! :-)
> >
> > Using SA 3.3.1 I have the following simple rule:
> >
> >     body   LOCAL_JH     /userid:\s*\n/i
> >
> > which should look for 'userid:', any number of spaces and then a NL
> > character (that is, there is nothing following the spaces on the same
> > line).
> >
> > If I send a message containing:
> >
> >    some text<NL>
> >    userid: <NL>
> >    some more text
> 
> The "body" rule processing collapses that paragraph into a single string, 
>
Ah, okay that would make sense. It would also explain why the use of the
'm' modifier didn't seem to work either (it would be matching at the
very end of the message).

> 
> Try this:
> 
>     rawbody LOCAL_JH /userid:\s*$/i
> 
That failed as-is, but by including the 'm' modifier it works fine :-)

I (now) notice that in the Mail::SpamAssassin::Conf man page it states
for 'rawbody':

     ...but HTML tags and line breaks will still be present.
     Multiline expressions will need to be used to match strings that
     are broken by line breaks.


Many thanks,

John.

-- 
John Horne                   Tel: +44 (0)1752 587287
University of Plymouth, UK   Fax: +44 (0)1752 587001

Re: Problem matching newline in body

Posted by John Hardin <jh...@impsec.org>.
On Fri, 21 May 2010, John Horne wrote:

> Hello,
>
> Can you tell it's Friday afternoon? What should be a simple problem
> always seems to become a nightmare on Friday afternoons! :-)
>
> Using SA 3.3.1 I have the following simple rule:
>
>     body   LOCAL_JH     /userid:\s*\n/i
>
> which should look for 'userid:', any number of spaces and then a NL
> character (that is, there is nothing following the spaces on the same
> line).
>
> If I send a message containing:
>
>    some text<NL>
>    userid: <NL>
>    some more text

The "body" rule processing collapses that paragraph into a single string, 
otherwise it would be easy for spammers to avoid most string matching by 
inserting line breaks.

Try this:

    rawbody LOCAL_JH /userid:\s*$/i

{untested, and caffiene levels are low, so no promises}

-- 
  John Hardin KA7OHZ                    http://www.impsec.org/~jhardin/
  jhardin@impsec.org    FALaholic #11174     pgpk -a jhardin@impsec.org
  key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C  AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
   Vista "security improvements" consist of attempting to shift blame
   onto the user when things go wrong.
-----------------------------------------------------------------------
  Today: the 6th anniversary of SpaceshipOne winning the X-prize

Re: Problem matching newline in body

Posted by John Horne <jo...@plymouth.ac.uk>.
On Fri, 2010-05-21 at 15:51 +0200, Yet Another Ninja wrote:
> On 2010-05-21 15:40, John Horne wrote:
> If I send a message containing:
> 
>     some text<NL>
>     userid: <NL>
>     some more text
...
> > 
> > Can someone show me how to match a newline character in the above rule
> > please?
> 
> can you post a spam sample @ pastebin?
>
No spam sample. This is just a simple test of matching a newline. I
tested it by sending a plain-text message containing literally the text
quoted above.


John.

-- 
John Horne                   Tel: +44 (0)1752 587287
University of Plymouth, UK   Fax: +44 (0)1752 587001

Re: Problem matching newline in body

Posted by Yet Another Ninja <sa...@alexb.ch>.
On 2010-05-21 15:40, John Horne wrote:
> Hello,
> 
> Can you tell it's Friday afternoon? What should be a simple problem
> always seems to become a nightmare on Friday afternoons! :-)
> 
> Using SA 3.3.1 I have the following simple rule:
> 
>      body   LOCAL_JH     /userid:\s*\n/i
> 
> which should look for 'userid:', any number of spaces and then a NL
> character (that is, there is nothing following the spaces on the same
> line).
> 
> If I send a message containing:
> 
>     some text<NL>
>     userid: <NL>
>     some more text
> 
> it fails. If I insert a NL before 'some more text', then it works.
> 
> I tried using '/userid:\s*$/mi', but that too didn't work.
> 
> 
> Can someone show me how to match a newline character in the above rule
> please?

can you post a spam sample @ pastebin?