NNTPC: Problem with Xref rewriting in 1.0.6

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Looking at the xover output from nntpcache 1.0.6, I found that the
"Xref:" header was being corrupted.  I was getting the some of the white
space dropped:

	Xref: alfie.demon.co.ukuk.telecom:80486 uk.net:15708

Looking deeper, I also discovered another problem.  When deciding
whether to keep a particular entry in the Xref header (if it refers to
a group that is served from the same server), it passes the complete
"group.name:1234" instead of just the group name, which means it will
only match against "*" in the server config file.

Here is a patch that fixes xrefRewrite and xrefRewriteCopy (I think --
I don't know how to trigger the copy version getting called).

--- xover.c~	Sat Apr 12 11:21:56 1997
+++ xover.c	Sat Apr 12 19:00:31 1997
@@ -152,19 +152,23 @@
 	 * useful to more intelligent newsreaders
 	 */
 	SKIPNOSPACE(s); /* hostname */
-	for (o=p=s; *s && *s!='\t' && *s!='\r' && *s!='\n';)
+	SKIPSPACE(s);
+	for (o=s; *s && *s!='\t' && *s!='\r' && *s!='\n';)
 	{
+		bool keep;
 		char c;
-		if (o!=s && *s == ' ' && *o != ' ')
-			*o++ = ' ';
-		SKIPSPACE(s);
 		p=s;
-		SKIPNOWHITE(s);
+		while (*s && *s!=':')
+			s++;
 		if (p==s)
 			break;
 		c=*s;
 		*s='\0';
-		if (getServerGroup(p) == scfg)
+		keep = getServerGroup(p) == scfg ? TRUE : FALSE;
+		*s = c;
+		SKIPNOWHITE(s);
+		SKIPSPACE(s);
+		if (keep)
 		{
 			if (o!=p)
 			{
@@ -174,7 +178,6 @@
 			} else
 				o=s;
 		}
-		*s=c;
 	}
 	if (s!=o)
 		memset(o, ' ', s-o);
@@ -208,17 +211,27 @@
 		*dst++=*s++; /* hostname */
 	while (*s == ' ')
 		*dst++=*s++;
-	for (p=s; *s && !isspace(*s);)
+	for (; *s && !isspace(*s);)
 	{
+		bool keep;
 		char c;
 		p=s;
-		while (*s && !isspace(*s))
+		while (*s && *s!=':')
 			*dst++=*s++; /* alt.suicide:1234 */
 		c=*s;
 		*s='\0';
-		if (getServerGroup(p) != scfg)
-			dst -= s-p;
+		keep = getServerGroup(p) == scfg ? TRUE : FALSE;
 		*s=c;
+		if (keep)
+		{
+			while (*s && !isspace(*s))
+				*dst++=*s++;
+		} else
+		{
+			dst -= s-p;
+			while (*s && !isspace(*s))
+				s++;
+		}
 		while (*s == ' ')
 			*dst++=*s++;
 	}

-- 
 `O O'  | Nick.Holloway@alfie.demon.co.uk  http://www.alfie.demon.co.uk/
// ^ \\ | Nick.Holloway@parallax.co.uk  http://www.parallax.co.uk/~alfie/


[Index of Archives]     [Yosemite]     [Yosemite Campsites]     [Bugtraq]     [Linux]     [Trn]

Powered by Linux