Article View: news.software.readers
Article #243232Dialog (regex defect): Action rule using "Header" scans into body of post
From: VanguardLH
Date: Fri, 12 Nov 2010 04:14
Date: Fri, 12 Nov 2010 04:14
94 lines
6207 bytes
6207 bytes
40tude Dialog
2.0.15.41 (beta 38)
Objective: Ignore a post if it came from a leech site (i.e., a web-based
forum running a web-to-NNTP gateway to Usenet so the forum can pretend
it has a larger audience or to provide a webnews-for-boobs interface to
Usenet).
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.
Any scanning of headers for values should be restricted to only the
header section of an article. The body should NOT be included. Per
RFC, the header and body are separated by the first blank line in the
article. That is, the header ends at the first \n\n sequence (newline
at the end of the last header line and the newline for the blank
delimiter line).
Since the action rule using "Header" ends up scanning beyond the header
section and wanders off into the body section, anything in the body that
is in the regex ends up completing a True for the test. I'll give an
example below (shown between the equal-sign delimiter lines):
==============================
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.
Obviously I'm not trying to test on header values that are strings down
in the body of the article! There are *no* headers past the blank
delimiter line and their values, even for multi-line values, do not
extend beyond that blank delimiter line.
When testing on a header value, parsing should stop at either the first
occurrence of \n\n (the blank line) or the next occurrence of ^\w+: (the
next header title which is always positioned at the start of a line
versus continuation lines that have leading spaces).
The use of Header in an action rule seems to look for that string to
appear anywhere in the article, including in the body, and also of
parsing its value off into the body section. I'm accustomed to using
the greedy versions of regex so maybe I need to think how to code the
regex to be non-greedy so somehow it cannot extend beyond a single line.
Since the .* seems to be what might be causing the parsing to continue
beyond the end of line (although I've tried using the $ end-of-line
character at the end of the regex), just how would I specify to look
within one line for a string (on a word boundary since I'm looking for
full words, not substrings)? While some headers can be multi-line, none
of those on which I test are that long.
Besides the Header operator, I have to wonder how many other posts have
been incorrectly tagged because parsing of the regex extended beyond the
the actual value of the named header. Maybe the From, Message-ID,
X-Ref, and other preset operators identifying headers are similarly
screwed up and end up testing the regex outside the value for the
specified header, extending into the values of other following headers,
and even into the body. Hopefully not and only the parsing of the
Header operator is screwed up; however, I have many action rules defined
that test on non-overview headers (since that is often the only way to
track a poster or source). That's why I have Dialog download the entire
article so I can test on all the headers. Takes longer to get Dialog
updated but then I only visit text-only groups and no binary groups.
Technical Details
Message-ID:
<ibieuc$fa1$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.ams3.giganews.com!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!weretis.net!feeder4.news.weretis.net!news.albasani.net!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <ibieuc$fa1$1@news.albasani.net> Subject: Dialog (regex defect): Action rule using "Header" scans into body of post Date: Thu, 11 Nov 2010 22:14:24 -0600 From: VanguardLH <V@nguard.LH> 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.ams3.giganews.com!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!weretis.net!feeder4.news.weretis.net!news.albasani.net!not-for-mail Newsgroups: news.software.readers Organization: 0.35MOA sniper at loose in Usenet Lines: 94 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net Pdd+rSM/u9MTdMK3HaoTbFaMhlk0kpfJCZYs9xwle1znohmfSJIhd/ssXr0n/AsXDW1QEBQWS3VkgSHCVZttafWdEoNtUERV0ySP1vKnFcSPDzJkBMOSPMI5n3Ghd1WH NNTP-Posting-Date: Fri, 12 Nov 2010 04:14:05 +0000 (UTC) Keywords: VanguardLH VLH811 Cancel-Lock: sha1:IUhEgASlUbQCx4nPjtuKjjcwzfc= User-Agent: 40tude_Dialog/2.0.15.41 Injection-Info: news.albasani.net; logging-data="PT9OKSX28SVEVQKIa3pT9F9jPVQRh87ef6FkXVOJpJdhtuxAahrCxiuGNdwzuMdmKbZ9RPG9apJLKTzLJqtbe69rZv+HPuyTQz+LMEjmMNg6wW/5lCG3Wm43v2QAvdJo"; 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: 5988