Article View: news.software.nntp
Article #79170Re: Cleanfeed - Any rules for invalid group names?
From: Peter J Ross
Date: Wed, 02 Jul 2008 17:07
Date: Wed, 02 Jul 2008 17:07
110 lines
4195 bytes
4195 bytes
In news.software.nntp on Wed, 25 Jun 2008 00:09:39 -0700, D. Stussy
<spam@bde-arc.ampr.org> wrote:
> Based on the valid names at isc.org -- with one modification (allowing a
> digit as the first character), I think the appropriate expression should be
> something close to:
>
> [a-z0-9]([-a-z0-9._+]*[-a-z0-9_+])*
Try this.
[a-z0-9][a-z0-9_+-]*(\.([a-z0-9][a-z0-9_+-])*)*
> I don't like having a dash ("-") or an underscore ("_") as the last
> character, but isc.org's page says that's valid. There are programming
> groups that end with plus ("+"), so those should be accepted. I think this
> also properly kills any double or multiple dot values (i.e. any string that
> has two or more consecutive periods).
Yours doesn't; mine should.
> Except for groups that use [A-Z],
You could use "(?i)" to switch off case-sensitivity.
> will this reject any valid group?
I don't think so.
> Is that a regex format acceptable to perl?
It's acceptable PCRE.
> I note that there are things that it won't check for:
> - A fully numeric name component.
> - The length requirement of any component.
> - The number of components.
> - Invalid components such as "all" or "ctl".
> ...But it's not meant to check for everything.
I have a few PCREs that I use to check for those errors (and others)
here: <http://pjr.lasnobberia.net/usenet/validator>. Some of this
snippet of PHP might be adaptable for your purposes:
#v+
if (preg_match ('/\s/', $groupName)) {
$fault = TRUE;
echo $errorWhiteSpace;
}
if (! preg_match ('/\./', $groupName)) {
$fault = TRUE;
echo $errorNoDots;
}
if (preg_match ('/^\./', $groupName)) {
$fault = TRUE;
echo $errorStartDots;
}
if (preg_match ('/\.\./', $groupName)) {
$fault = TRUE;
echo $errorConsecDots;
}
if (preg_match ('/\.$/', $groupName)) {
$fault = TRUE;
echo $errorEndDots;
}
if (preg_match ('/^(control|to|example)\./', $groupName)) {
$fault = TRUE;
echo $errorForbiddenHierarchy;
}
if (preg_match ('/\.(all|ctl)(\.|$)/', $groupName)) {
$fault = TRUE;
echo $errorAllCtl;
}
if (preg_match ('/^[^a-z]/', $groupName)) {
$fault = TRUE;
echo $errorStartLetter;
}
if (preg_match ('/[^a-z0-9._+\s-]/', $groupName)) {
$fault = TRUE;
echo $errorInvalidChars;
}
if (preg_match ('/(^|\.)[0-9]+($|\.)/', $groupName)) {
$fault = TRUE;
echo $errorOnlyDigits;
}
if (preg_match ('/(^|\.)[+_-]/', $groupName)) {
$fault = TRUE;
echo $errorPlusMin;
}
if (preg_match ('/_/', $groupName)) {
if (preg_match('/^(comp|humanities|misc|news|rec|sci|soc|talk)\./', $groupName)) {
$fault = TRUE;
echo $errorUnderscore;
}
}
foreach ($groupNameComponents as $value) {
if (strlen($value) > 30) {
$fault = TRUE;
echo $errorLongComponent;
}
}
#v-
--
PJR :-)
<http://pjr.lasnobberia.net/>
<http://slrn-doc.sourceforge.net/>
Technical Details
Message-ID:
<slrng6ndff.5jv.pjr@pjr.motzarella.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!feeder.news-service.com!news.motzarella.org!motzarella.org!not-for-mailReferences:
<g3sqvk$8eh$1@snarked.org>Show Full Headers
Complete Article Headers
Message-ID: <slrng6ndff.5jv.pjr@pjr.motzarella.org> Subject: Re: Cleanfeed - Any rules for invalid group names? Date: Wed, 02 Jul 2008 17:07:59 +0000 From: Peter J Ross <pjr@example.invalid> References: <g3sqvk$8eh$1@snarked.org> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!feeder.news-service.com!news.motzarella.org!motzarella.org!not-for-mail Newsgroups: news.software.nntp Organization: none Lines: 110 Reply-To: Peter J Ross <peadar.ruadh@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: reader.motzarella.org U2FsdGVkX1+8TqqJAu/48AG7VulSbwfUVnagiBaDnZp1AHXFJZIWMnz7uA+q52zI3Ztq8nfsQw4uDXQhJ9zIPjxE3Yq7KW6oLzkQw7pTh1cJ8Nui4CjS7ieJzv9SGIm76Qn6UnxSd+o= X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Wed, 2 Jul 2008 17:07:59 +0000 (UTC) X-Auth-Sender: U2FsdGVkX18L8lZllkdHrzW/OJJu6ScS Cancel-Lock: sha1:4YdP9YGi1hqDICFEn+0B2tzEPGI= User-Agent: slrn/pre0.9.9-112/mm (Linux)