INN commit: trunk/nnrpd (perl.c)
INN Commit
Russ_Allbery at isc.org
Mon May 4 19:11:53 UTC 2009
Date: Monday, May 4, 2009 @ 12:11:52
Author: iulius
Revision: 8442
Fix a bug in nnrpd Perl filter hook: undefining an header
or setting it to an empty value ("") generated an empty
header line ("In-Reply-To: \r\n" for instance).
Doing that now totally removes the header.
Modified:
trunk/nnrpd/perl.c
--------+
perl.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
Modified: perl.c
===================================================================
--- perl.c 2009-05-03 22:12:50 UTC (rev 8441)
+++ perl.c 2009-05-04 19:11:52 UTC (rev 8442)
@@ -82,7 +82,7 @@
ENTER;
SAVETMPS;
- /* Create the Perl Hash. */
+ /* Create the Perl hash. */
hdr = perl_get_hv("hdr", true);
for (hp = Table; hp < EndOfTable; hp++) {
if (hp->Body)
@@ -107,6 +107,7 @@
t = (*s == ' ' ? s + 1 : s);
(void) hv_store(hdr, p, (s - p) - 1, newSVpv(t, 0), 0);
}
+
/* Store user. */
sv_setpv(perl_get_sv("user", true), PERMuser);
@@ -119,7 +120,7 @@
SPAGAIN;
- /* Restore headers. */
+ /* Restore headers if they have just been modified by the filter. */
modswitch = perl_get_sv("modify_headers", false);
HeadersModified = false;
if (SvTRUE(modswitch)) {
@@ -132,7 +133,8 @@
hv_iterinit(hdr);
while ((scan = hv_iternext(hdr)) != NULL) {
- /* Get the values. */
+ /* Get the values. We replace the known ones with these
+ * new values. */
p = HePV(scan, len);
s = SvPV(HeVAL(scan), PL_na);
#ifdef DEBUG_MODIFY
@@ -157,14 +159,16 @@
}
if (hp != EndOfTable)
continue;
-
- /* Add to other headers. */
- if (i >= OtherSize - 1) {
- OtherSize += 20;
- OtherHeaders = xrealloc(OtherHeaders, OtherSize * sizeof(char *));
+
+ /* Add to other headers if not empty. */
+ if (TrimSpaces(s) > 0) {
+ if (i >= OtherSize - 1) {
+ OtherSize += 20;
+ OtherHeaders = xrealloc(OtherHeaders, OtherSize * sizeof(char *));
+ }
+ t = concat(p, ": ", s, (char *) 0);
+ OtherHeaders[i++] = t;
}
- t = concat(p, ": ", s, (char *) 0);
- OtherHeaders[i++] = t;
}
OtherCount = i;
#ifdef DEBUG_MODIFY
More information about the inn-committers
mailing list