Article View: news.software.nntp
Article #82675Re: unrelated possible bug with C flag?
From: Julien ÉLIE
Date: Wed, 27 Jan 2010 20:48
Date: Wed, 27 Jan 2010 20:48
97 lines
4561 bytes
4561 bytes
Answering to myself:
> --- art.c (révision 8911)
> +++ art.c (copie de travail)
> @@ -2159,13 +2159,24 @@
> }
>
> if (HDR_FOUND(HDR__FOLLOWUPTO)) {
> - for (i = 0, p = HDR(HDR__FOLLOWUPTO) ; (p = strchr(p, ',')) != NULL ;
> - i++, p++)
> - continue;
> + for (i = 0, p = HDR(HDR__FOLLOWUPTO) ; p != NULL && *p != '\0'; p++) {
> + /* Skip leading whitespaces. */
> + for (; *p && ISWHITE(*p) ; p++)
> + continue;
I've improved the patch to also skip folding whitespaces and take into
account Russ' remark about "poster" when used in a newsgroup list.
The whole process would be:
if (HDR_FOUND(HDR__FOLLOWUPTO)) {
PosterGroup = false;
for (i = 0, p = HDR(HDR__FOLLOWUPTO) ; p != NULL && *p != '\0'; p++) {
/* Skip leading whitespaces. */
p = (char *) skip_fws(p);
if (*p != '\0' && *p != ',')
i++;
/* Check whether "poster" is in the header field. */
if (strncasecmp(p, "poster", 6) == 0
&& (p[6] == ',' || p[6] == ' ' || p[6] == '\t'
|| p[6] == '\r' || p[6] == '\n' || p[6] == '\0')) {
PosterGroup = true;
}
if ((p = strchr(p, ',')) == NULL)
break;
}
/* When "poster" is the only value, then it is not a followup.
* Otherwise, it is a followup to a newsgroup named "poster". */
if (PosterGroup && i == 1) {
data->Followcount = 0;
} else {
data->Followcount = i;
}
} else {
data->Followcount = data->Groupcount;
}
With this new skip_fws function (designed like the existing skip_cfws):
--- lib/headers.c (révision 8880)
+++ lib/headers.c (copie de travail)
@@ -86,3 +86,32 @@
}
return p;
}
+
+
+/*
+** Skip any amount of FWS (folding whitespace), the RFC 5322 grammar term
+** for whitespace and CRLF pairs. We also allow simple newlines since we don't
+** always deal with wire-format messages. Note that we do not attempt to
+** ensure that CRLF or a newline is followed by whitespace. Returns the new
+** position of the pointer.
+*/
+const char *
+skip_fws(const char *p)
+{
+ for (; *p != '\0'; p++) {
+ switch (*p) {
+ case ' ':
+ case '\t':
+ case '\n':
+ break;
+ case '\r':
+ if (p[1] != '\n')
+ return p;
+ break;
+ default:
+ return p;
+ }
+ }
+ return p;
+}
--
Julien ÉLIE
« -- Ouvre l'œil, et le bon !
-- L'autre, je peux pas encore l'ouvrir, je risque pas de me tromper ! » (Astérix)
Technical Details
Message-ID:
<hjq8r4$s5h$1@news.trigofacile.com>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!num2.nntp.dca.giganews.com!num1.nntp.dca.giganews.com!number.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news2.euro.net!feeds.phibee-telecom.net!de-l.enfer-du-nord.net!gegeweb.org!news.trigofacile.com!.POSTED.aaubervilliers-151-1-9-10.w83-114.abo.wanadoo.fr!not-for-mailReferences:
<hic74m$vi8$1@news.trigofacile.com> <hicf9f$ntj$1@snarked.org> <hiclo9$dd4$1@news.trigofacile.com> <hidmvp$vh1$1@snarked.org> <hitipd$rtb$1@news.trigofacile.com> <hiu2ar$707$1@snarked.org> <hiun2p$2mt$1@news.trigofacile.com> <hj0m9c$g98$1@snarked.org> <hj7qh0$ggu$1@news.trigofacile.com> <hj8csn$cok$1@snarked.org> <hjaiid$f7c$1@news.trigofacile.com> <hjar9t$mq$1@snarked.org> <hjnpm4$f5l$1@news.trigofacile.com>Show Full Headers
Complete Article Headers
Message-ID: <hjq8r4$s5h$1@news.trigofacile.com> Subject: Re: unrelated possible bug with C flag? Date: Wed, 27 Jan 2010 21:48:41 +0100 From: Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> References: <hic74m$vi8$1@news.trigofacile.com> <hicf9f$ntj$1@snarked.org> <hiclo9$dd4$1@news.trigofacile.com> <hidmvp$vh1$1@snarked.org> <hitipd$rtb$1@news.trigofacile.com> <hiu2ar$707$1@snarked.org> <hiun2p$2mt$1@news.trigofacile.com> <hj0m9c$g98$1@snarked.org> <hj7qh0$ggu$1@news.trigofacile.com> <hj8csn$cok$1@snarked.org> <hjaiid$f7c$1@news.trigofacile.com> <hjar9t$mq$1@snarked.org> <hjnpm4$f5l$1@news.trigofacile.com> 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!num2.nntp.dca.giganews.com!num1.nntp.dca.giganews.com!number.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news2.euro.net!feeds.phibee-telecom.net!de-l.enfer-du-nord.net!gegeweb.org!news.trigofacile.com!.POSTED.aaubervilliers-151-1-9-10.w83-114.abo.wanadoo.fr!not-for-mail Newsgroups: news.software.nntp Organization: TrigoFACILE -- http://www.trigofacile.com/ Lines: 97 Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=response Content-Transfer-Encoding: 8bit Injection-Date: Wed, 27 Jan 2010 20:48:36 +0000 (UTC) Injection-Info: news.trigofacile.com; posting-host="aaubervilliers-151-1-9-10.w83-114.abo.wanadoo.fr:83.114.8.10"; logging-data="28849"; mail-complaints-to="abuse@trigofacile.com" In-Reply-To: <hjnpm4$f5l$1@news.trigofacile.com> X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6002.18005 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18005