Article View: news.software.readers
Article #243243Re: Dialog (regex defect): Action rule using "Header" scans into body of post
From: VanguardLH
Date: Mon, 15 Nov 2010 18:42
Date: Mon, 15 Nov 2010 18:42
101 lines
6312 bytes
6312 bytes
Oliver Cromm wrote:
> * VanguardLH:
>
>> Action rule:
>>
>> !ignore,markread Header {^User-Agent: .*\b(gateway|NewsPortal|PHP)\b.*$}
>>
>> Originally I did not have the ".*$" at the end of the regex since I
>> figured it parsed to the end of the line or to the end of the value for
>> a header (i.e., it stopped parsing when it either hit another header
>> line or the blank delimiter line). Wrong, as I found out and noted
>> below. However, adding the trailing "$" to denote the end of line does
>> not restrict the parsing to just the same line as where the header title
>> string is found.
>>
>> Expected result:
>> - Header does not exist. Rule does not fire.
>> - Header exists. No match on regex for its value. Rule does not fire.
>> - Header exists. Match on regex for its value. Rule fires.
>>
>> Problem:
>> The "Header" operator does NOT restrict the parsing to only the header
>> section of the article. It scans through the ENTIRE article, including
>> the body.
>
> [...]
>
>> ==============================
>> From: someone <email@domain.tld>
>> Newsgroup: <pickone>
>> <moreHeaders>
>> User-Agent: Mozilla(yadda...yadda...yadda...
>> <moreHeaders>
>>
>> First line (after blank delimiter line) of body. User want drivers for
>> a Gateway model and need drivers for an old version of Windows.
>> ==============================
>>
>> From the action rule given above, it should NOT fire. There is no
>> "gateway", "newsportal", or "php" words in the value for the User-Agent
>> header. But what does Dialog do? It matches all the way from the
>> "User-Agent" header title in the header section, past the blank
>> delimiter line and into the body to end its match at the end of the
>> "Gateway" word in the body.
>
> I tested this specific example, and the rule did not fire for me. Are
> you sure that there wasn't a match anywhere in the Header below the
> User-Agent line?
Ah, I checked (I use a clipboard manager so I could go find the copy of
the problematic post, headers and body, that I snipped before). You're
right. There was an occurrence of "gateway" in another header. The
Subject header had "Cannot install Windows XP 32-bit on my Gateway ...".
In this case, the User-Agent header was positioned before the Subject
header hence why my action rule fired accidentally. For some reason, my
eyes saw what I only wanted to see and that didn't include looking at
the content of the Subject header. DOH!
> In any case, the solution to your problem should be turning off
> multi-line matching with (?-m):
>
> !ignore,markread Header {(?-m)^User-Agent: .*\b(gateway|NewsPortal|PHP)\b.*$}
Thanks for that info. While I use regex often, there is still a ton of
it that I don't know. Sometimes it just boggles my mind too much when I
start digging into PCRE as to just how complicated you can make the
expressions. I'll see if your suggestion works to force the regex to
search only on one line. I had assumed that was the default but looks
like I was wrong.
> I remember my initial confusion because the standard parameters for
> RegEx in Scoring are ignore-case and match-multiline. So just in case,
> also remember (?-i), the parameter to make the match case-sensitive.
Yeah, I found out about the default of case-insensitive searching but it
makes the typical regex easier to compose. I have a couple rules where
I use it, as in:
^(Re:\s*)?(?-i)[^a-z]*$
where I am checking if the poster (in a starter post or in a reply) had
no lowercase alphanumeric characters in the Subject header, like it was
all uppercase (i.e., they're screaming) and/or non-alphabetic characters
(i.e., all digits, dollar signs, parens, etc.).
The default of case-insensitive matches I knew about and understand why
that is the default. I didn't realize the Header search spanned
multiple lines but then thinking about it then that is probably a
requirement since header values often span more than one line, like the
Received header; however, it wouldv'e made a lot more sense to terminate
a search on the specified header when the \n\n was found (marking the
end of the headers section) or when the next header title was found
(starts at byte 1 in a line with no spaces in the title and following
within whitespace with a colon character). But then there is no
InHeaders operator to specify looking anywhere in any header and across
headers (i.e., a substring match on all text in all headers).
Thanks for the heads up on the multi-line prefix for regex. Something
new I learned. Hopefully I won't later run across a User-Agent header
that is so long that it uses multiple lines.
Technical Details
Message-ID:
<ibrutm$26h$1@news.albasani.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!border1.nntp.dca3.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.albasani.net!not-for-mailReferences:
<ibieuc$fa1$1@news.albasani.net> <4jnelelbf8ic.dlg@mid.crommatograph.info>Show Full Headers
Complete Article Headers
Message-ID: <ibrutm$26h$1@news.albasani.net> Subject: Re: Dialog (regex defect): Action rule using "Header" scans into body of post Date: Mon, 15 Nov 2010 12:42:56 -0600 From: VanguardLH <V@nguard.LH> References: <ibieuc$fa1$1@news.albasani.net> <4jnelelbf8ic.dlg@mid.crommatograph.info> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!border1.nntp.dca3.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.albasani.net!not-for-mail Newsgroups: news.software.readers Organization: 0.35MOA sniper at loose in Usenet Lines: 101 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net 2QSCiGBU9EnhU9nOWwEMr4y7vO889n45QkCfAuOFjEVwOicQyUZKKrchDob04PNpPDR+tI7A+KEc+djf+pMDmg== NNTP-Posting-Date: Mon, 15 Nov 2010 18:41:58 +0000 (UTC) Keywords: VanguardLH VLH811 Cancel-Lock: sha1:Vb8Udh68Bn2Rn+RA5LUjX87lL/Q= User-Agent: 40tude_Dialog/2.0.15.41 Injection-Info: news.albasani.net; logging-data="8xOng0e4tsgeLggBid1cKNiVJ1vlivzV+sCwrHExxSImQDuinK0b55Mxy7ERbKP1C04vAMoxfEtpZYd7/6r9WILrxMfzEoDwW1vobufh0s+vDcGy0ZUJ+wqrXgwB+nqy"; mail-complaints-to="abuse@albasani.net" X-MOTD: It is wiser to remain silent and let others ponder your ignorance than to speak and remove all doubt X-Original-Bytes: 6097