πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #84247

Re: Empty folded line in header field (was Re: Censure ?)

#84247
From: Florian Schlichting
Date: Tue, 09 Aug 2011 12:39
89 lines
5461 bytes
Hi Julien,

On 2011-07-24, Julien Γ‰LIE wrote:
> X-Face: u<)b%~v7<8fL[]Wuuwi1xF$eOV]yWTt-UU6AdQf*1@Djz]J&-5]F}of4|7TL;
>    
>      "%JRG^C*#<b$:_DkLf#v0}Y-IJ)PG
> Message-ID:<4e231311$0$1752$426a74cc@news.free.fr>

> The second line of the X-Face: header field is "   \r\n", which is invalid
> per RFC 5322:

> It is an example of article that would fail proper distribution.
> innd properly relays it.
> pullnews does not (it is how I noticed the issue):  it reports "Fixing bad header"
> and afterwards fails to detect the message-ID (considered to be in the body of the
> message).
> Hmm???  nnrpd accepts to inject the article.  Something that needs being changed??? :-)

Both pullnews and nnrpd would be expected to fix the header by cutting
the illegal line, no?

pullnews seems to assume that a header line containing only whitespace
must be a broken transition to the message body, hence it can't find a
Message-ID. I think pullnews could be a little more intelligent about
this and have a look at the following line; if it's in "Headername:
header body" format, or another continuing line starting with
whitespace, then perhaps that can count as a sufficient indicator that
we're still in the header?

Note that the first two chunks of this patch address a different issue
introduced to the 2.5 branch with the INN::Util::Shlock commit; things
seem to be a little different in the trunk branch, but if pullnews is to
be used independently of an INN installation, then perhaps it should not
make use of INN::Util::Shlock at all?

Subject: [PATCH] pullnews: fix all-whitespace header lines

--- a/frontends/Makefile
+++ b/frontends/Makefile
@@ -97,7 +97,7 @@ ovdb_stat.o: ovdb_stat.c
 cnfsheadconf:	cnfsheadconf.in  $(FIX)	; $(FIX) cnfsheadconf.in
 cnfsstat:	cnfsstat.in      $(FIX)	; $(FIX) cnfsstat.in
 mailpost:	mailpost.in      $(FIX)	; $(FIX) mailpost.in
-pullnews:	pullnews.in      $(FIX)	; $(FIX) -i pullnews.in
+pullnews:	pullnews.in      $(FIX)	; $(FIX) pullnews.in
 scanspool:	scanspool.in     $(FIX)	; $(FIX) scanspool.in
 
 bunbatch: Makefile ../Makefile.global
--- a/frontends/pullnews.in
+++ b/frontends/pullnews.in
@@ -1,4 +1,5 @@
 #! /usr/bin/perl -w
+# fixscript will replace this line with code to load INN::Config
 #
 # Author:       James Brister <brister@vix.com> -- berkeley-unix --
 # Start Date:   Sat, 10 Oct 1998 21:40:11 +0200
@@ -720,15 +721,24 @@ sub crossFeedGroup {
                     $xref = 1;
                 }
 
-                # Catch some of the more common problems with articles.
-                if ($article->[$idx] =~ m!^\s+\n$! and $curr_hdr ne 'subject') {
+                # Fix header lines containing only whitespace
+                if ($article->[$idx] =~ m!^\s+\n$!) {
                     print STDERR "Fixing bad header line[$idx]-1: $article->[$idx-1]" if $idx > 0;
                     print STDERR "Fixing bad header line[$idx]::: $article->[$idx]";
                     print STDERR "Fixing bad header line[$idx]+1: $article->[$idx+1]";
-                    # Do not use $line_len here because $article->[$idx] has been modified
-                    # since the length was computed.
-                    $tx_len -= length($article->[$idx]) - 1;
-                    $article->[$idx] = "\n";
+                    # try to guess if next line is still a header or beginning of body
+                    if ($article->[$idx+1] =~ /^\S+:/ or $article->[$idx+1] =~ /^\s+\S/) {
+                        print STDERR "\tCUTTING illegal empty header line[$idx]\n";
+                        # Do not use $line_len here because $article->[$idx] has been modified
+                        # since the length was computed.
+                        $tx_len -= length($article->[$idx]);
+                        splice @$article, $idx, 1;
+                        $idx--;
+                    } else {
+                        print STDERR "\tFORCING body at line[$idx]\n";
+                        $tx_len -= length($article->[$idx]) - 1;
+                        $article->[$idx] = "\n";
+                    }
                 }
 
                 $headers = 0 if $article->[$idx] eq "\n";

Florian
Technical Details
Message-ID: <9aco4fFv07U1@mid.uni-berlin.de>
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!border1.nntp.ams3.giganews.com!border1.nntp.ams2.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!fu-berlin.de!uni-berlin.de!not-for-mail
References: <mn.8c0c7db70f4125e7.121321@tellas.gr> <ivv2jt$273a$1@talisker.lacave.net> <4e231311$0$1752$426a74cc@news.free.fr> <j0i4vv$p8j$1@news.trigofacile.com> <j0i6d5$qt7$1@news.trigofacile.com>

Show Full Headers
Complete Article Headers
Message-ID: <9aco4fFv07U1@mid.uni-berlin.de>
Subject: Re: Empty folded line in header field (was Re: Censure ?)
Date: Tue, 09 Aug 2011 12:39:43 +0000
From: Florian Schlichting <Florian.Schlichting@fu-berlin.de>
References: <mn.8c0c7db70f4125e7.121321@tellas.gr> <ivv2jt$273a$1@talisker.lacave.net> <4e231311$0$1752$426a74cc@news.free.fr> <j0i4vv$p8j$1@news.trigofacile.com> <j0i6d5$qt7$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!border1.nntp.ams3.giganews.com!border1.nntp.ams2.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!fu-berlin.de!uni-berlin.de!not-for-mail
Newsgroups: news.software.nntp
Followup-To: news.software.nntp
Organization: Freie Universitaet Berlin
Lines: 89
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de
 HQlUh2YRErSTTMmSuXEaYgEY1si05o447jXBUJRbGhN0pRJQhkzQUl
User-Agent: slrn/pre1.0.0-18 (Linux)
X-Original-Bytes: 5132