diff --git a/doc/pod/news.pod b/doc/pod/news.pod index 5edea60a6..952a7112a 100644 --- a/doc/pod/news.pod +++ b/doc/pod/news.pod @@ -54,6 +54,16 @@ is not. Thanks to Enrik Berkhan for the patch for B. =item * +Fixed the computation of the Bytes header field by B (in header-only +mode with the B<-B> flag). + +=item * + +Fixed the generation of B batches by B (when using the B<-r> +flag) which had not the expected native LF line termination. + +=item * + B no longer malfunctions nor throttles when the maximum number of file descriptors supported by the system is reached. If needing to use more file descriptors than the default system limit, a new C option diff --git a/frontends/pullnews.in b/frontends/pullnews.in index 0d8809cec..5f6c321be 100644 --- a/frontends/pullnews.in +++ b/frontends/pullnews.in @@ -11,6 +11,11 @@ # Full changelog can be found in the Git commit history of the # INN project. Major changes are: # +# December 2023: +# Julien Élie fixed the computation of the Bytes header field, +# the use of trailing LF in rnews batches (-r option), and +# trailing CRLF in generated header fields. +# # February-March 2023: # Julien Élie added TLS support for both downstream and upstream # servers. Also made pullnews robust on socket timeout and lock @@ -1008,6 +1013,7 @@ sub crossFeedGroup { for (my $idx = 0; $idx < @{$article}; $idx++) { $line_len = length($article->[$idx]); $len += $line_len; + # Dot-stuffing already undone by Net::NNTP. $tx_len += $line_len; $info{server}->{$server}->{bytes} += $line_len; $info{bytes} += $line_len; @@ -1150,7 +1156,7 @@ sub crossFeedGroup { my $xref_h = "Xref: " . $upstreamParams->{$server}->{name} - . " $group:$i\n"; + . " $group:$i\r\n"; splice(@{$article}, $idx_blank_pre_body, 0, $xref_h); $tx_len += length($xref_h); $idx_blank_pre_body++; @@ -1159,12 +1165,11 @@ sub crossFeedGroup { if ($add_bytes_header) { # Compute the number of bytes the same way the :bytes # metadata item would do. The additional Bytes header - # field is not counted, as well as header fields removed by - # pullnews. - my $bytes_real_count = $tx_len + scalar(@{$article}); - my $bytes_h = "Bytes: $bytes_real_count\n"; + # field is not counted (as it does not form part of the + # article in a header-only feed), as well as header fields + # removed by pullnews. + my $bytes_h = "Bytes: $tx_len\r\n"; splice(@{$article}, $idx_blank_pre_body, 0, $bytes_h); - $tx_len += length($bytes_h); $idx_blank_pre_body++; } @@ -1173,10 +1178,6 @@ sub crossFeedGroup { and @{$article} > $idx_blank_pre_body + 1) { splice(@{$article}, $idx_blank_pre_body + 1); - $tx_len = 0; - for my $line (@{$article}) { - $tx_len += length($line); - } } if (not $skip_due_to_hdrs and ref $hashfeed) { @@ -1207,8 +1208,17 @@ sub crossFeedGroup { ) . "\n"; } } elsif ($rnews) { - printf RNEWS "#! rnews %d\n", $tx_len; - map { print RNEWS $_ } @{$article}; + # Change all trailing CRLF to LF as rnews expects articles + # in native format (rnews converts them to wire format when + # processing them). + # Net::NNTP has already removed dot-stuffing. + my $artwithoutCR = ""; + foreach my $line (@{$article}) { + $line =~ s/\r\n$/\n/; + $artwithoutCR .= $line; + } + printf RNEWS "#! rnews %d\n", length($artwithoutCR); + print RNEWS $artwithoutCR; print LOG "+" unless $quiet; $fed{$group}++; $info{'rnews'}->{fed}++;