INN commit: branches/2.5 (8 files)

INN Commit rra at isc.org
Mon Feb 8 20:54:58 UTC 2010


    Date: Monday, February 8, 2010 @ 12:54:57
  Author: iulius
Revision: 8962

Fixed a bug in the newsfeeds "C" flag:  the count of followup groups
was one less than the real number.  When the value of the Followup-To:
header is "poster", it is no longer considered to be a followup.

Also fixed the default value of the "C" flag:  2 instead of 1.

Thanks to Dieter Stussy for the patch.

Modified:
  branches/2.5/CONTRIBUTORS
  branches/2.5/doc/pod/news.pod
  branches/2.5/include/inn/libinn.h
  branches/2.5/innd/art.c
  branches/2.5/innd/newsfeeds.c
  branches/2.5/lib/headers.c
  branches/2.5/lib/vector.c
  branches/2.5/lib/wire.c

----------------------+
 CONTRIBUTORS         |    2 +-
 doc/pod/news.pod     |    9 ++++++++-
 include/inn/libinn.h |    1 +
 innd/art.c           |   30 ++++++++++++++++++++++--------
 innd/newsfeeds.c     |    2 +-
 lib/headers.c        |   29 +++++++++++++++++++++++++++++
 lib/vector.c         |    4 ++--
 lib/wire.c           |    4 ++--
 8 files changed, 66 insertions(+), 15 deletions(-)

Modified: CONTRIBUTORS
===================================================================
--- CONTRIBUTORS	2010-02-08 20:54:29 UTC (rev 8961)
+++ CONTRIBUTORS	2010-02-08 20:54:57 UTC (rev 8962)
@@ -266,7 +266,7 @@
 Chris Caputo, Thomas Parleman, Adam J. Richter, Jim Dutton, Julien Elie,
 Ray Miller, Andreas M. Kirchwitz, Andrey Yakovlev, Christoph Biedl,
 Kai Gallasch, Ollivier Robert, Ivan Shmakov, Kachun Lee, Kirill Berezin,
-D. Stussy, Alan Schwartz, Shalon Wood, Nick Couchman, Jakub Bogusz,
+Dieter Stussy, Alan Schwartz, Shalon Wood, Nick Couchman, Jakub Bogusz,
 J. Thomas Halliley, Matija Nalis, Geraint A. Edwards, Alexander Bartolich,
 David Hlacik, Andreas Mattheiss, James Ralston, Wim Lewis, Johan van Selst,
 Wolfgang M. Weyand, Berend Reitsma, William Kronert, Petr Novopashenniy,

Modified: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod	2010-02-08 20:54:29 UTC (rev 8961)
+++ doc/pod/news.pod	2010-02-08 20:54:57 UTC (rev 8962)
@@ -252,7 +252,7 @@
 that prevented overview data from being generated when poisoned groups
 were specified but a latter sub-pattern made the group wanted.  A uwildmat
 expression is now correctly handled, and a potential segfault has been fixed.
-Thanks to S<D. Stussy> for the bug report.
+Thanks to Dieter Stussy for the bug report.
 
 =item *
 
@@ -281,6 +281,13 @@
 
 =item *
 
+Fixed a bug in the F<newsfeeds> B<C> flag:  the count of followup groups
+was one less than the real number.  When the value of the Followup-To:
+header is C<poster>, it is no longer considered to be a followup.
+Thanks to Dieter Stussy for the patch.
+
+=item *
+
 B<batcher> has not supported the retrieval of an article with its
 file name for a long time.  The B<-S> flag is therefore removed.
 

Modified: include/inn/libinn.h
===================================================================
--- include/inn/libinn.h	2010-02-08 20:54:29 UTC (rev 8961)
+++ include/inn/libinn.h	2010-02-08 20:54:57 UTC (rev 8962)
@@ -157,6 +157,7 @@
 extern bool             IsValidMessageID(const char *string, bool stripspaces);
 extern bool             IsValidHeaderName(const char *string);
 extern const char *     skip_cfws(const char *p);
+extern const char *     skip_fws(const char *p);
 extern void             HeaderCleanFrom(char *from);
 extern struct _DDHANDLE * DDstart(FILE *FromServer, FILE *ToServer);
 extern void               DDcheck(struct _DDHANDLE *h, char *group);

Modified: innd/art.c
===================================================================
--- innd/art.c	2010-02-08 20:54:29 UTC (rev 8961)
+++ innd/art.c	2010-02-08 20:54:57 UTC (rev 8962)
@@ -1066,8 +1066,8 @@
       data->Expires = 0;
   }
 
-  /* Colon or whitespace in the Newsgroups header? */
-  /* assumes Newsgroups header is required header */
+  /* Colon or whitespace in the Newsgroups: header? */
+  /* Assumes Newsgroups: header is required header. */
   if ((data->Groupcount =
     NGsplit(HDR(HDR__NEWSGROUPS), HDR_LEN(HDR__NEWSGROUPS),
     &data->Newsgroups)) == 0) {
@@ -2159,16 +2159,30 @@
   }
 
   if (HDR_FOUND(HDR__FOLLOWUPTO)) {
-    for (i = 0, p = HDR(HDR__FOLLOWUPTO) ; (p = strchr(p, ',')) != NULL ;
-      i++, p++)
-      continue;
+    /* Count the number of commas without syntactically parsing the header. */
+    for (i = 1, p = HDR(HDR__FOLLOWUPTO) ; (p = strchr(p, ',')) != NULL ;
+         i++, p++) ;
+
     data->Followcount = i;
+
+    /* When "poster" is the only value, then it is not a followup. */
+    if (i == 1) {
+      /* Skip leading whitespaces. */
+      p = (char *) skip_fws(HDR(HDR__FOLLOWUPTO));
+
+      /* Check for an empty header field or "poster". */
+      if (*p == '\0' || (strncasecmp(p, "poster", 6) == 0
+          && (p[6] == ' ' || p[6] == '\t' || p[6] == '\0'
+              || p[6] == '\r' || p[6] == '\n'))) {
+        data->Followcount = 0;
+      }
+    }
+  } else {
+    data->Followcount = data->Groupcount;
   }
-  if (data->Followcount == 0)
-    data->Followcount = data->Groupcount;
 
   groups = data->Newsgroups.List;
-  /* Parse the Control header. */
+  /* Parse the Control: header. */
   LikeNewgroup = false;
   if (HDR_FOUND(HDR__CONTROL)) {
     IsControl = true;

Modified: innd/newsfeeds.c
===================================================================
--- innd/newsfeeds.c	2010-02-08 20:54:29 UTC (rev 8961)
+++ innd/newsfeeds.c	2010-02-08 20:54:57 UTC (rev 8962)
@@ -560,7 +560,7 @@
 	    if (*++p && CTYPE(isdigit, *p))
 		sp->Crosscount = atoi(p);
 	    else
-		sp->Crosscount = 1;
+		sp->Crosscount = 2;
 	    break;
 	case 'F':
 	    if (*++p == '\0')

Modified: lib/headers.c
===================================================================
--- lib/headers.c	2010-02-08 20:54:29 UTC (rev 8961)
+++ lib/headers.c	2010-02-08 20:54:57 UTC (rev 8962)
@@ -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;
+}
+

Modified: lib/vector.c
===================================================================
--- lib/vector.c	2010-02-08 20:54:29 UTC (rev 8961)
+++ lib/vector.c	2010-02-08 20:54:57 UTC (rev 8962)
@@ -296,7 +296,7 @@
 
 /*
 **  Given a string, split it at whitespace to form a vector, copying each
-**  string segment.  If the fourth argument isn't NULL, reuse that vector;
+**  string segment.  If the second argument isn't NULL, reuse that vector;
 **  otherwise, allocate a new one.  Any number of consecutive whitespace
 **  characters is considered a single separator.
 */
@@ -328,7 +328,7 @@
 
 /*
 **  Given a string, split it at whitespace to form a vector, destructively
-**  modifying the string to nul-terminate each segment.  If the fourth
+**  modifying the string to nul-terminate each segment.  If the second
 **  argument isn't NULL, reuse that vector; otherwise, allocate a new one.
 **  Any number of consecutive whitespace characters is considered a single
 **  separator.

Modified: lib/wire.c
===================================================================
--- lib/wire.c	2010-02-08 20:54:29 UTC (rev 8961)
+++ lib/wire.c	2010-02-08 20:54:57 UTC (rev 8962)
@@ -101,7 +101,7 @@
 **  takes us past the end of data, return NULL.
 */
 static char *
-skip_fws(char *text, const char *end)
+skip_fws_bounded(char *text, const char *end)
 {
     char *p;
 
@@ -144,7 +144,7 @@
         else if (isheader(p, header, headerlen)) {
             p += headerlen + 2;
             if (stripspaces)
-                p = skip_fws(p, end);
+                p = skip_fws_bounded(p, end);
             if (p == NULL)
                 return NULL;
             if (p >= end || p[0] != '\r' || p[1] != '\n')




More information about the inn-committers mailing list