INN commit: branches/2.5/nnrpd (article.c misc.c nnrpd.h)
INN Commit
rra at isc.org
Sun Nov 15 09:27:31 UTC 2009
Date: Sunday, November 15, 2009 @ 01:27:31
Author: iulius
Revision: 8789
HDR, XHDR and XPAT were not properly showing leading spaces
in header values.
Besides, CR and LF were both changed to spaces. It is not what
should be done: CRLF should be removed and CR, LF, NUL, TAB
should be changed to spaces after the removal of CRLF.
Modified:
branches/2.5/nnrpd/article.c
branches/2.5/nnrpd/misc.c
branches/2.5/nnrpd/nnrpd.h
-----------+
article.c | 39 ++++++++++++++++++++++++++-------------
misc.c | 4 ++--
nnrpd.h | 2 +-
3 files changed, 29 insertions(+), 16 deletions(-)
Modified: article.c
===================================================================
--- article.c 2009-11-15 09:27:11 UTC (rev 8788)
+++ article.c 2009-11-15 09:27:31 UTC (rev 8789)
@@ -468,10 +468,10 @@
** Return the header from the specified file, or NULL if not found.
*/
char *
-GetHeader(const char *header)
+GetHeader(const char *header, bool stripspaces)
{
const char *p, *q, *r, *s, *t;
- char *w, prevchar;
+ char *w, *wnew, prevchar;
/* Bogus value here to make sure that it isn't initialized to \n. */
char lastchar = ' ';
const char *limit;
@@ -492,9 +492,12 @@
}
if ((lastchar == '\n') || (p == ARThandle->data)) {
headerlen = strlen(header);
- if (strncasecmp(p, header, headerlen) == 0 && p[headerlen] == ':') {
- for (; (p < limit) && !isspace((int)*p) ; p++);
- for (; (p < limit) && isspace((int)*p) ; p++);
+ if (strncasecmp(p, header, headerlen) == 0 && p[headerlen] == ':' &&
+ ISWHITE(p[headerlen+1])) {
+ p += headerlen + 2;
+ if (stripspaces) {
+ for (; (p < limit) && ISWHITE(*p) ; p++);
+ }
for (q = p; q < limit; q++)
if ((*q == '\r') || (*q == '\n')) {
/* Check for continuation header lines. */
@@ -506,7 +509,7 @@
break;
}
if ((*t == '\t' || *t == ' ')) {
- for (; (t < limit) && isspace((int)*t) ; t++);
+ for (; (t < limit) && ISWHITE(*t) ; t++);
q = t;
} else {
break;
@@ -571,9 +574,19 @@
memcpy(retval, p, q - p);
*(retval + (int)(q - p)) = '\0';
}
- for (w = retval; *w; w++)
- if (*w == '\n' || *w == '\r')
- *w = ' ';
+ for (w = retval, wnew = retval; *w; w++) {
+ if (*w == '\r' && w[1] == '\n') {
+ w++;
+ continue;
+ }
+ if (*w == '\0' || *w == '\t' || *w == '\r' || *w == '\n') {
+ *wnew = ' ';
+ } else {
+ *wnew = *w;
+ }
+ wnew++;
+ }
+ *wnew = '\0';
return retval;
}
}
@@ -690,7 +703,7 @@
}
if (ac > 1)
ARTnumber = tart;
- if ((msgid = GetHeader("Message-ID")) == NULL) {
+ if ((msgid = GetHeader("Message-ID", true)) == NULL) {
ARTclose();
Reply("%s\r\n", ARTnoartingroup);
return;
@@ -755,7 +768,7 @@
}
if (!ARTopen(ARTnumber))
continue;
- msgid = GetHeader("Message-ID");
+ msgid = GetHeader("Message-ID", true);
ARTclose();
} while (msgid == NULL);
@@ -1191,7 +1204,7 @@
Reply("%d Header information for %s follows (from the article)\r\n",
hdr ? NNTP_OK_HDR : NNTP_OK_HEAD, av[1]);
- if ((text = GetHeader(av[1])) != NULL
+ if ((text = GetHeader(av[1], false)) != NULL
&& (!pattern || uwildmat_simple(text, pattern)))
Printf("%s %s\r\n", hdr ? "0" : p, text);
else if (hdr) {
@@ -1231,7 +1244,7 @@
hdr ? NNTP_OK_HDR : NNTP_OK_HEAD, av[1]);
HasNotReplied = false;
}
- p = GetHeader(header);
+ p = GetHeader(header, false);
if (p && (!pattern || uwildmat_simple(p, pattern))) {
snprintf(buff, sizeof(buff), "%lu ", i);
SendIOb(buff, strlen(buff));
Modified: misc.c
===================================================================
--- misc.c 2009-11-15 09:27:11 UTC (rev 8788)
+++ misc.c 2009-11-15 09:27:31 UTC (rev 8789)
@@ -71,9 +71,9 @@
if (!PERMspecified)
return false;
- if ((p = GetHeader("Xref")) == NULL) {
+ if ((p = GetHeader("Xref", true)) == NULL) {
/* In case article does not include Xref:. */
- if ((p = GetHeader("Newsgroups")) != NULL) {
+ if ((p = GetHeader("Newsgroups", true)) != NULL) {
if (!NGgetlist(&grplist, p))
/* No newgroups or null entry. */
return true;
Modified: nnrpd.h
===================================================================
--- nnrpd.h 2009-11-15 09:27:11 UTC (rev 8788)
+++ nnrpd.h 2009-11-15 09:27:31 UTC (rev 8789)
@@ -219,7 +219,7 @@
extern void UnlockPostRec(char *path);
extern int RateLimit(long *sleeptime, char *path);
extern void ExitWithStats(int x, bool readconf);
-extern char *GetHeader(const char *header);
+extern char *GetHeader(const char *header, bool stripspaces);
extern void GRPreport(void);
extern bool NGgetlist(char ***argvp, char *list);
extern bool PERMartok(void);
More information about the inn-committers
mailing list