🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
33 messages
33 total messages Started by dunno Mon, 09 May 2016 00:15
Multiple occurences of header fields
#87424
Author: dunno
Date: Mon, 09 May 2016 00:15
98 lines
3515 bytes
First I would like to show some code. Here is how my NNTP server works with
headers:

parse_headers ($) {
	my ($headers) = @_;
	my $hdr = {};
	my ($last_key, $last_cell);

	my @headers = split /\r\n/s, $$headers;

	foreach my $headerline (@headers) {
		return undef if length($headerline) > 998;
		return undef if $headerline =~ /^\s+$/;

		if ($headerline =~ m/^(\S+): (.+)$/) {
			my $header_name = lc $1;
			my $header_body = $2;

			return undef if $header_body =~ /^\s*$/;
			unless (exists $hdr->{$header_name}) {
				$last_key = $header_name;
				$last_cell = 0;
				$hdr->{$header_name} = [ $header_body ];
			} else {
				$last_key = $header_name;
				$last_cell = scalar @{ $hdr->{$header_name} };
				$hdr->{$header_name} = [ @{ $hdr->{$header_name} }, $header_body ];
			}
		} else {
			return undef unless ((defined $last_key) and (defined $last_cell));
			$hdr->{$last_key}[$last_cell] .= "\r\n$headerline";
		}
	}

	return $hdr;
}

sub stringify_headers ($) {
	my $hdr = shift;
	my $header = '';

	foreach my $header_name ( keys %$hdr ) {
		for (my $i = 0; $i < scalar @{ $hdr->{$header_name} }; $i++) {
			$header .= "$header_name: $hdr->{$header_name}[$i]\r\n";
		}
	}
	return \$header;
}

As you can see, initially all headers are treated as if they can occur more
than once. While validating article I also check that certain headers
mentioned in RFC 5536 do not occur more than once:

sub no_duplicate_headers ($) {
	my $hdr = shift;
	my @headers_names = qw(
		approved
		archive
		control
		distribution
		expires
		followup-to
		injection-date
		injection-info
		keywords
		lines
		message-id
		newsgroups
		organization
		path
		summary
		supersedes
		user-agent
	);

	foreach my $header_name ( @headers_names ) {
		if (exists $hdr->{$header_name}) {
			if (scalar @{ $hdr->{$header_name} } > 1) {
				return undef;
			}
		}
	}

	return 1;
}

That is my understanding of RFC: unless multiple occurrences of header
field are explicitly prohibited, they are allowed and therefore should be
preserved in injected article. However, it seems that nnrpd is stripping
every occurrence of header field except the last one. Am I missing
something? Is there any specific reason for that? I can tell that innd
allows multiple occurrences because I see multiple X-Abuse-And-DMCA-Info:
headers in articles propagated from Giganews.

-- 
dunno

Re: Multiple occurences of header fields
#87427
Author: Julien ÉLIE
Date: Mon, 09 May 2016 19:46
67 lines
3273 bytes
dunno,

> That is my understanding of RFC: unless multiple occurrences of header
> field are explicitly prohibited, they are allowed and therefore should be
> preserved in injected article. However, it seems that nnrpd is stripping
> every occurrence of header field except the last one. Am I missing
> something?

Please give an example, and the version of INN you are using.

Just tested with INN 2.6.0, and it works as expected:

POST
340 Ok, recommended message-ID <ngqp7i$59g$1@news.trigofacile.com>
From: =?ISO-8859-15?Q?Julien_=C9LIE?= <iulius@nom-de-mon-site.com.invalid>
Newsgroups: fr.test
Subject: Duplications
Date: Mon, 09 May 2016 21:19:01 +0200 (CEST)
Comments: Comment 1
X-Test-Multiple: 1
Comments: Comment 2
X-Test-Multiple: 2
X-Test-Multiple: And 3

plop
..
240 Article received <ngqp7i$59g$1@news.trigofacile.com>
ARTICLE <ngqp7i$59g$1@news.trigofacile.com>
220 0 <ngqp7i$59g$1@news.trigofacile.com> article
Path: news.trigofacile.com!.POSTED.news.trigofacile.com!not-for-mail
From: =?ISO-8859-15?Q?Julien_=C9LIE?= <iulius@nom-de-mon-site.com.invalid>
Newsgroups: fr.test
Subject: Duplications
Date: Mon, 09 May 2016 21:19:01 +0200 (CEST)
Organization: Groupes francophones par TrigoFACILE
Message-ID: <ngqp7i$59g$1@news.trigofacile.com>
Injection-Date: Mon, 9 May 2016 19:42:48 -0000 (UTC)
Injection-Info: news.trigofacile.com; posting-account="<localhost>"; posting-host="news.trigofacile.com:2001:41d0:1:6d44::1";
	logging-data="5424"; mail-complaints-to="abuse@trigofacile.com"
Comments: Comment 1
X-Test-Multiple: 1
Comments: Comment 2
X-Test-Multiple: 2
X-Test-Multiple: And 3
Xref: news.trigofacile.com fr.test:36877

plop
..



nnrpd did not strip anything.



> Is there any specific reason for that? I can tell that innd
> allows multiple occurrences because I see multiple X-Abuse-And-DMCA-Info:
> headers in articles propagated from Giganews.

And so does nnrpd.

-- 
Julien ÉLIE

« Rien ne serpe de courir ! » (Druides gaulois)

Re: Multiple occurences of header fields
#87428
Author: dunno
Date: Tue, 10 May 2016 06:32
76 lines
3826 bytes
Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> wrote:
> dunno,
> 
>> That is my understanding of RFC: unless multiple occurrences of header
>> field are explicitly prohibited, they are allowed and therefore should be
>> preserved in injected article. However, it seems that nnrpd is stripping
>> every occurrence of header field except the last one. Am I missing
>> something?
> 
> Please give an example, and the version of INN you are using.
> 
> Just tested with INN 2.6.0, and it works as expected:
> 
> POST
> 340 Ok, recommended message-ID <ngqp7i$59g$1@news.trigofacile.com>
> From: =?ISO-8859-15?Q?Julien_=C9LIE?= <iulius@nom-de-mon-site.com.invalid>
> Newsgroups: fr.test
> Subject: Duplications
> Date: Mon, 09 May 2016 21:19:01 +0200 (CEST)
> Comments: Comment 1
> X-Test-Multiple: 1
> Comments: Comment 2
> X-Test-Multiple: 2
> X-Test-Multiple: And 3
> 
> plop
> .
> 240 Article received <ngqp7i$59g$1@news.trigofacile.com>
> ARTICLE <ngqp7i$59g$1@news.trigofacile.com>
> 220 0 <ngqp7i$59g$1@news.trigofacile.com> article
> Path: news.trigofacile.com!.POSTED.news.trigofacile.com!not-for-mail
> From: =?ISO-8859-15?Q?Julien_=C9LIE?= <iulius@nom-de-mon-site.com.invalid>
> Newsgroups: fr.test
> Subject: Duplications
> Date: Mon, 09 May 2016 21:19:01 +0200 (CEST)
> Organization: Groupes francophones par TrigoFACILE
> Message-ID: <ngqp7i$59g$1@news.trigofacile.com>
> Injection-Date: Mon, 9 May 2016 19:42:48 -0000 (UTC)
> Injection-Info: news.trigofacile.com; posting-account="<localhost>";
> posting-host="news.trigofacile.com:2001:41d0:1:6d44::1";
> 	logging-data="5424"; mail-complaints-to="abuse@trigofacile.com"
> Comments: Comment 1
> X-Test-Multiple: 1
> Comments: Comment 2
> X-Test-Multiple: 2
> X-Test-Multiple: And 3
> Xref: news.trigofacile.com fr.test:36877
> 
> plop
> .
> 
> 
> 
> nnrpd did not strip anything.
> 
> 
> 
>> Is there any specific reason for that? I can tell that innd
>> allows multiple occurrences because I see multiple X-Abuse-And-DMCA-Info:
>> headers in articles propagated from Giganews.
> 
> And so does nnrpd.
> 

I found where the problem is. It's in nnrpd Perl filter, documented in
~/doc/hook-perl. It actually mentioned in documentation. Instead of using
hash of arrays of strings, like I do, it uses hash of strings, so it cannot
support multiple occurrences of any header fields. Except that it treat
"Comments:" and "comments:" as different headers, lol. 

Same with innd Perl filter, but it does not modify the headers.

-- 
dunno

Re: Multiple occurences of header fields
#87429
Author: Julien ÉLIE
Date: Tue, 10 May 2016 19:34
45 lines
2961 bytes
dunno,

> I found where the problem is. It's in nnrpd Perl filter, documented in
> ~/doc/hook-perl. It actually mentioned in documentation. Instead of using
> hash of arrays of strings, like I do, it uses hash of strings, so it cannot
> support multiple occurrences of any header fields.

Changing the use of strings to hashes of strings would unfortunately 
break existing nnrpd Perl filters, so it is not something I am inclined 
to do (unless introducing a new %hdrfull hash with that behaviour for 
instance).


> Except that it treat
> "Comments:" and "comments:" as different headers, lol.

It may be something to fix, as hash keys are case-sensitive for Perl.
A suggestion would be to somehow normalize the name of the header 
(capitalize the initial character and any character following a char 
different from [a-zA-Z]? -> "X-Trace" for instance).
Does it sound the right thing to do?


By the way, I see in RFC 5322 that a field name consists of:

    ftext           =   %d33-57 /          ; Printable US-ASCII
                        %d59-126           ;  characters not including
                                           ;  ":".

So basically "X-#%-T`!" is a valid header field name.
Has anyone here already tried to send articles with that unusual syntax?



> Same with innd Perl filter, but it does not modify the headers.

And I think innd Perl filter won't give you two answers for "Comments:" 
and "comments:", but only the contents of the first occurrence, will it?

-- 
Julien ÉLIE

« Rien ne serpe de courir ! » (Druides gaulois)

Re: Multiple occurences of header fields
#87430
Author: dunno
Date: Wed, 11 May 2016 01:48
61 lines
3907 bytes
Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> wrote:
> dunno,
> 
>> I found where the problem is. It's in nnrpd Perl filter, documented in
>> ~/doc/hook-perl. It actually mentioned in documentation. Instead of using
>> hash of arrays of strings, like I do, it uses hash of strings, so it cannot
>> support multiple occurrences of any header fields.
> 
> Changing the use of strings to hashes of strings would unfortunately 
> break existing nnrpd Perl filters, so it is not something I am inclined 
> to do (unless introducing a new %hdrfull hash with that behaviour for 
> instance).

I would suggest to introduce new %header hash, and declare %hdr as obsolete
in documentation, leaving it for backward compatibility. I see why rapid
changes are not welcomed, but it does not mean that software don't have to
evolve.

>> Except that it treat
>> "Comments:" and "comments:" as different headers, lol.
> 
> It may be something to fix, as hash keys are case-sensitive for Perl.
> A suggestion would be to somehow normalize the name of the header 
> (capitalize the initial character and any character following a char 
> different from [a-zA-Z]? -> "X-Trace" for instance).
> Does it sound the right thing to do?

It seems that INN is already normalizing the names of some headers (for
example, "newsgroups:" is converted to "Newsgroups:" in injected articles.)

I understand  some software (such as custom scripts) might be unaware of
the fact that headers' names are case-insensitive, so it might explicitly
look for header name "Message-ID", thus missing the "message-id". However,
I'm not sure if any server software or newsreader would do that. Would
there be any considerable effect on the network if all headers were lower
case?

> By the way, I see in RFC 5322 that a field name consists of:
> 
>    ftext           =   %d33-57 /          ; Printable US-ASCII
>                        %d59-126           ;  characters not including
>                                           ;  ":".
> 
> So basically "X-#%-T`!" is a valid header field name.
> Has anyone here already tried to send articles with that unusual syntax?

I just tried to send such article to mixmin.net and it didn't work. I'm
away from my computer, so I cannot test it on my installation of INN.

> 
>> Same with innd Perl filter, but it does not modify the headers.
> 
> And I think innd Perl filter won't give you two answers for "Comments:" 
> and "comments:", but only the contents of the first occurrence, will it?

I assume so; unfortunately, cannot test it at the moment.

-- 
dunno

Re: Multiple occurences of header fields
#87431
Author: dunno
Date: Wed, 11 May 2016 02:10
68 lines
4265 bytes
dunno <dunno@dunno.dunno> wrote:
> Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> wrote:
>> dunno,
>> 
>>> I found where the problem is. It's in nnrpd Perl filter, documented in
>>> ~/doc/hook-perl. It actually mentioned in documentation. Instead of using
>>> hash of arrays of strings, like I do, it uses hash of strings, so it cannot
>>> support multiple occurrences of any header fields.
>> 
>> Changing the use of strings to hashes of strings would unfortunately 
>> break existing nnrpd Perl filters, so it is not something I am inclined 
>> to do (unless introducing a new %hdrfull hash with that behaviour for 
>> instance).
> 
> I would suggest to introduce new %header hash, and declare %hdr as obsolete
> in documentation, leaving it for backward compatibility. I see why rapid
> changes are not welcomed, but it does not mean that software don't have to
> evolve.
> 
>>> Except that it treat
>>> "Comments:" and "comments:" as different headers, lol.
>> 
>> It may be something to fix, as hash keys are case-sensitive for Perl.
>> A suggestion would be to somehow normalize the name of the header 
>> (capitalize the initial character and any character following a char 
>> different from [a-zA-Z]? -> "X-Trace" for instance).
>> Does it sound the right thing to do?
> 
> It seems that INN is already normalizing the names of some headers (for
> example, "newsgroups:" is converted to "Newsgroups:" in injected articles.)
> 
> I understand  some software (such as custom scripts) might be unaware of
> the fact that headers' names are case-insensitive, so it might explicitly
> look for header name "Message-ID", thus missing the "message-id". However,
> I'm not sure if any server software or newsreader would do that. Would
> there be any considerable effect on the network if all headers were lower
> case?
> 
>> By the way, I see in RFC 5322 that a field name consists of:
>> 
>> ftext           =   %d33-57 /          ; Printable US-ASCII
>> %d59-126           ;  characters not including
>> ;  ":".
>> 
>> So basically "X-#%-T`!" is a valid header field name.
>> Has anyone here already tried to send articles with that unusual syntax?
> 
> I just tried to send such article to mixmin.net and it didn't work. I'm
> away from my computer, so I cannot test it on my installation of INN.
> 
>> 
>>> Same with innd Perl filter, but it does not modify the headers.
>> 
>> And I think innd Perl filter won't give you two answers for "Comments:" 
>> and "comments:", but only the contents of the first occurrence, will it?
> 
> I assume so; unfortunately, cannot test it at the moment.
> 

Correction: IIRC, when innd Perl filter builds %hdr hash, it puts only
certain standard header fields in it. If it does not normalize header
names, then it might consider "comments:" as non-standard header field,
thus it will just skip it.

-- 
dunno

Re: Multiple occurences of header fields
#87432
Author: Russ Allbery
Date: Wed, 11 May 2016 02:32
20 lines
1885 bytes
Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> writes:

> By the way, I see in RFC 5322 that a field name consists of:

>    ftext           =   %d33-57 /          ; Printable US-ASCII
>                        %d59-126           ;  characters not including
>                                           ;  ":".

> So basically "X-#%-T`!" is a valid header field name.
> Has anyone here already tried to send articles with that unusual syntax?

I think INN copes.  I guess I'll find out with this article.  :)

-- 
Russ Allbery (eagle@eyrie.org)              <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.

Re: Multiple occurences of header fields
#87434
Author: Bruce Esquibel
Date: Wed, 11 May 2016 11:06
17 lines
1532 bytes
Russ Allbery <eagle@eyrie.org> wrote:

> I think INN copes.  I guess I'll find out with this article.  :)


I'm running an older version of INN and seems to work fine:

X-Complaints-To: action@cs.stanford.edu
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
X-#%-T!: Fun headers!
Cancel-Lock: sha1:+Qfbv3WpUEhf2mgNGuCgwpi3EDU=
Xref: news.ripco.com news.software.nntp:124350

-bruce
bje@ripco.com

Re: Multiple occurences of header fields
#87433
Author: David Ritz
Date: Wed, 11 May 2016 16:07
57 lines
3737 bytes
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--0-1492423626-1462981808=:14592
Content-Type: text/plain; CHARSET=UTF-8
Content-Transfer-Encoding: 8BIT
Content-ID: <alpine.OSX.2.20.1605111050531.14592@mako.ath.cx>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday, 10 May 2016 19:32 -0700, 
 in article <87oa8djpeh.fsf@hope.eyrie.org>, 
 Russ Allbery <eagle@eyrie.org> wrote:

> Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> writes:

>> By the way, I see in RFC 5322 that a field name consists of:

>>    ftext           =   %d33-57 /          ; Printable US-ASCII
>>                        %d59-126           ;  characters not including
>>                                           ;  ":".

>> So basically "X-#%-T`!" is a valid header field name. Has anyone 
>> here already tried to send articles with that unusual syntax?

> I think INN copes.  I guess I'll find out with this article.  :)

INN is far more liberal than that.  It will allow posts with field 
names which fall outside the allowed range.  (It's not alone in this 
respect.) See <news:56B76743.EEE5A71B@Man.works>.

Here I am referring to this header, which begins with the 
non-printing control character, DEL (ascii decimal 127, ascii 
hexadecimal 7F, carat notation ^?):

WTF-EH?: Mozilla 4.79 [en] (Win98; U)

    %d127WTF-EH?: Mozilla 4.79 [en] (Win98; U)
    \0x7FWTF-EH?: Mozilla 4.79 [en] (Win98; U)
    ^?WTF-EH?: Mozilla 4.79 [en] (Win98; U)

Keep in mind, that non-printing control characters are hard to see.

- -- 
David Ritz <dritz@mindspring.com>
 Be kind to animals; kiss a shark.

-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAlczWMMACgkQUrwpmRoS3uu/rQCg67jxSCnWCNd/TU6AoxrPnXIA
Io8An0OTD8g1JX4HpXZ1VBx5t6pgCpAH
=1LU2
-----END PGP SIGNATURE-----
--0-1492423626-1462981808=:14592--

Re: Multiple occurences of header fields
#87435
Author: Russ Allbery
Date: Wed, 11 May 2016 16:17
20 lines
1910 bytes
David Ritz <dritz@mindspring.com> writes:

> INN is far more liberal than that.  It will allow posts with field 
> names which fall outside the allowed range.  (It's not alone in this 
> respect.) See <news:56B76743.EEE5A71B@Man.works>.

> Here I am referring to this header, which begins with the 
> non-printing control character, DEL (ascii decimal 127, ascii 
> hexadecimal 7F, carat notation ^?):

Note that those are allowed by the obsolete syntax in RFC 5322, so this
was originally for moderately defensible reasons.

-- 
Russ Allbery (eagle@eyrie.org)              <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.

Re: Multiple occurences of header fields
#87436
Author: Julien ÉLIE
Date: Wed, 11 May 2016 20:24
30 lines
2411 bytes
Hi David and Russ,

>> INN is far more liberal than that.  It will allow posts with field
>> names which fall outside the allowed range.  (It's not alone in this
>> respect.) See <news:56B76743.EEE5A71B@Man.works>.
>
>> Here I am referring to this header, which begins with the
>> non-printing control character, DEL (ascii decimal 127, ascii
>> hexadecimal 7F, carat notation ^?):
>
> Note that those are allowed by the obsolete syntax in RFC 5322, so this
> was originally for moderately defensible reasons.

And it seems that nnrpd MUST go on accepting these headers provided by 
posting agents, though using an obsolete syntax.

RFC 5322:

4.  Obsolete Syntax
[...]
    Though these syntactic
    forms MUST NOT be generated according to the grammar in section 3,
    they MUST be accepted and parsed by a conformant receiver.

-- 
Julien ÉLIE

« Rien ne serpe de courir ! » (Druides gaulois)

Re: Multiple occurences of header fields
#87437
Author: Julien ÉLIE
Date: Wed, 11 May 2016 20:28
29 lines
2398 bytes
> And it seems that nnrpd MUST go on accepting these headers provided by
> posting agents, though using an obsolete syntax.

Oh, in fact NOT, because of RFC 5536:

    An article that uses the obsolete syntax specified in Section 4 of
    [RFC5322] is NOT conformant to this specification, except for the
    following two cases:

    o  Articles are conformant if they use the <obs-phrase> construct
       (use of a phrase like "John Q. Public" without the use of quotes,
       see Section 4.1 of [RFC5322]), but agents MUST NOT generate
       productions of such syntax.

    o  Articles are conformant if they use the "GMT" <zone>, as specified
       in Section 3.1.1.


And also RFC 3977:

      header-name = 1*A-NOTCOLON
      A-NOTCOLON = %x21-39 / %x3B-7E

-- 
Julien ÉLIE

« L'ordinateur obéit à vos ordres, pas à vos intentions. »

Re: Multiple occurences of header fields
#87439
Author: David Ritz
Date: Sat, 14 May 2016 18:43
57 lines
3986 bytes
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--0-1537694138-1463250576=:44007
Content-Type: text/plain; CHARSET=UTF-8
Content-Transfer-Encoding: 8BIT
Content-ID: <alpine.OSX.2.20.1605141329592.44007@mako.ath.cx>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday, 11 May 2016 22:28 +0200, 
 in article <nh04lo$40t$1@news.trigofacile.com>, 
 Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> wrote:

>> And it seems that nnrpd MUST go on accepting these headers provided 
>> by posting agents, though using an obsolete syntax.

> Oh, in fact NOT, because of RFC 5536:

>    An article that uses the obsolete syntax specified in Section 4 
>    of [RFC5322] is NOT conformant to this specification, except for 
>    the following two cases:

>    o Articles are conformant if they use the <obs-phrase> construct
>      (use of a phrase like "John Q. Public" without the use of 
>      quotes, see Section 4.1 of [RFC5322]), but agents MUST NOT 
>      generate productions of such syntax.
> 
>    o Articles are conformant if they use the "GMT" <zone>, as 
>      specified  in Section 3.1.1.

> And also RFC 3977:

>      header-name = 1*A-NOTCOLON
>      A-NOTCOLON = %x21-39 / %x3B-7E

All of these refer to obsolete usage in header field bodies.  The 
instance to which I refer deals with the appearance of %7F as the 
leading character in a header field _name_.  I'm not seeing anything 
which would indicate that this was ever acceptable, going as far back 
as RFC822.  Please correct me, but to me this suggests that it cannot 
be construed as obsolete, as it was never allowed.

- -- 
David Ritz <dritz@mindspring.com>
 Be kind to animals; kiss a shark.

-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAlc3ceAACgkQUrwpmRoS3utAnQCg7KpAterifiHjD+5g0pzfxLu/
ZcQAn0vcJ52PvBdrkyiEpb6Kmw1KVxZs
=Iy/Z
-----END PGP SIGNATURE-----
--0-1537694138-1463250576=:44007--

Re: Multiple occurences of header fields
#87438
Author: Russ Allbery
Date: Sat, 14 May 2016 19:21
19 lines
2114 bytes
David Ritz <dritz@mindspring.com> writes:

> All of these refer to obsolete usage in header field bodies.  The
> instance to which I refer deals with the appearance of %7F as the
> leading character in a header field _name_.  I'm not seeing anything
> which would indicate that this was ever acceptable, going as far back as
> RFC822.  Please correct me, but to me this suggests that it cannot be
> construed as obsolete, as it was never allowed.

Ah, indeed, you appear to be correct.  Control characters aren't allowed
in ftext, and even obsolete syntax doesn't change that.

-- 
Russ Allbery (eagle@eyrie.org)              <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.

Re: Multiple occurences of header fields
#87440
Author: David Ritz
Date: Tue, 17 May 2016 17:09
62 lines
4016 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday, 14 May 2016 12:21 -0700, 
 in article <87a8jso37o.fsf@hope.eyrie.org>, 
 Russ Allbery <eagle@eyrie.org> wrote:

> David Ritz <dritz@mindspring.com> writes:

>> All of these refer to obsolete usage in header field bodies.  The 
>> instance to which I refer deals with the appearance of %7F as the 
>> leading character in a header field _name_.  I'm not seeing 
>> anything which would indicate that this was ever acceptable, going 
>> as far back as RFC822.  Please correct me, but to me this suggests 
>> that it cannot be construed as obsolete, as it was never allowed.

> Ah, indeed, you appear to be correct.  Control characters aren't 
> allowed in ftext, and even obsolete syntax doesn't change that.

I'd also like to solicit some opinions on these examples.

Header name consisting of eight BS (%d08, %x08)
    ^H^H^H^H^H^H^H^H: Mozilla 4.79 [en] (Win98; U)
: Mozilla 4.79 [en] (Win98; U)

Header name consisiting of eight DEL (%d127, %x7F)
    ^?^?^?^?^?^?^?^?: Mozilla 4.79 [en] (Win98; U)
: Mozilla 4.79 [en] (Win98; U)

In the following examples nonprinting control characters are included 
in the header body.

DEL (%d127, %x7F)
From: "SpamGuy" <"Spam"@Guy.com>
    (From: "S^?p^?a^?m^?G^?u^?y" <"S^?p^?a^?m"@G^?u^?y^?.^?c^?o^?m>)
From: "SpamGuy" <"Spam"@Guy.com>
    (From: "S^?p^?a^?m^?G^?u^?y" <"S^?p^?a^?m"@^?G^?u^?y^?.^?c^?o^?m>)
From: =?iso-8859-1?Q?S=A0p=A0a=A0m=A0G=A0u=A0y?= <Spam@Guy.com>
    (From: =?iso-8859-1?Q?S=A0p=A0a=A0m=A0G=A0u=A0y?= <S^?p^?a^?m@^?G^?u^?y^?.^?c^?o^?m>)

Record Separator (%d30, %x1E)
From: SpamGuy <Spam@guy.com>
    (From: S^^p^^a^^m^^G^^u^^y <S^^p^^a^^m^^@^^g^^u^^y^^.^^c^^o^^m>)

Unit Separtator (%d31, %x1F)
From: SpamGuy <Spam@guy.com>
    (From: S^_p^_a^_m^_G^_u^_y <S^_p^_a^_m^_@^_g^_u^_y^_.^_c^_o^_m>)
From: Virus Guy <Virus@guy.com>
    (From: Virus Guy <Virus@^_g^_u^_y^_.^_c^_o^_m>)

- -- 
David Ritz <dritz@mindspring.com>
 Be kind to animals; kiss a shark.

-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAlc7UFsACgkQUrwpmRoS3uvhuwCfRmGO0wvLZWNr6fmhFt7vV7ge
AiYAoL7CLTHs99h+K4p6zGCDeXXifs1H
=oJVV
-----END PGP SIGNATURE-----

Re: Multiple occurences of header fields
#87442
Author: Julien ÉLIE
Date: Sun, 22 May 2016 13:40
77 lines
4811 bytes
Hi David,

> I'd also like to solicit some opinions on these examples.
>
> Header name consisting of eight BS (%d08, %x08)
>     ^H^H^H^H^H^H^H^H: Mozilla 4.79 [en] (Win98; U)
> : Mozilla 4.79 [en] (Win98; U)
>
> Header name consisiting of eight DEL (%d127, %x7F)
>     ^?^?^?^?^?^?^?^?: Mozilla 4.79 [en] (Win98; U)
> : Mozilla 4.79 [en] (Win98; U)
>
> In the following examples nonprinting control characters are included
> in the header body.
>
> DEL (%d127, %x7F)
> From: "SpamGuy" <"Spam"@Guy.com>
>     (From: "S^?p^?a^?m^?G^?u^?y" <"S^?p^?a^?m"@G^?u^?y^?.^?c^?o^?m>)
> From: "SpamGuy" <"Spam"@Guy.com>
>     (From: "S^?p^?a^?m^?G^?u^?y" <"S^?p^?a^?m"@^?G^?u^?y^?.^?c^?o^?m>)
> From: =?iso-8859-1?Q?S=A0p=A0a=A0m=A0G=A0u=A0y?= <Spam@Guy.com>
>     (From: =?iso-8859-1?Q?S=A0p=A0a=A0m=A0G=A0u=A0y?= <S^?p^?a^?m@^?G^?u^?y^?.^?c^?o^?m>)
>
> Record Separator (%d30, %x1E)
> From: SpamGuy <Spam@guy.com>
>     (From: S^^p^^a^^m^^G^^u^^y <S^^p^^a^^m^^@^^g^^u^^y^^.^^c^^o^^m>)
>
> Unit Separtator (%d31, %x1F)
> From: SpamGuy <Spam@guy.com>
>     (From: S^_p^_a^_m^_G^_u^_y <S^_p^_a^_m^_@^_g^_u^_y^_.^_c^_o^_m>)
> From: Virus Guy <Virus@guy.com>
>     (From: Virus Guy <Virus@^_g^_u^_y^_.^_c^_o^_m>)

I believe all of these examples MUST NOT be generated by posting agents 
and MUST be rejected by injecting agents.  (That's why nnrpd MUST reject 
them.)
Once injected, a relaying agent MAY reject them (section 3.6 of RFC 
5537).  (innd currently does not reject them, and I think we should keep 
that behaviour.)


Rationale
---------

RFC 2822 (now obsoleted by RFC 5322) allowed

NO-WS-CTL       =       %d1-8 /         ; US-ASCII control characters
                         %d11 /          ;  that do not include the
                         %d12 /          ;  carriage return, line feed,
                         %d14-31 /       ;  and white space characters
                         %d127

in the "unstructured" syntax of most of headers.
Now, RFC 5322 forbids it, even in obsolete syntax:

2.2.  Header Fields

    Header fields are lines beginning with a field name, followed by a
    colon (":"), followed by a field body, and terminated by CRLF.  A
    field name MUST be composed of printable US-ASCII characters (i.e.,
    characters that have values between 33 and 126, inclusive), except
    colon.  A field body may be composed of printable US-ASCII characters
    as well as the space (SP, ASCII value 32) and horizontal tab (HTAB,
    ASCII value 9) characters (together known as the white space
    characters, WSP).  A field body MUST NOT include CR and LF except
    when used in "folding" and "unfolding", as described in section
    2.2.3.  All field bodies MUST conform to the syntax described in
    sections 3 and 4 of this specification.

-- 
Julien ÉLIE

« – Ce n'était pas ma question.
   – C'était p'têt pas vot'question, oui, mais c'est ma
     réponse ! » (Georges Marchais répondant à Alain Duhamel)

Re: Multiple occurences of header fields
#87443
Author: Julien ÉLIE
Date: Sun, 22 May 2016 13:43
24 lines
2255 bytes
Hi David,

>>> So basically "X-#%-T`!" is a valid header field name. Has anyone
>>> here already tried to send articles with that unusual syntax?
>
> INN is far more liberal than that.  It will allow posts with field
> names which fall outside the allowed range.  (It's not alone in this
> respect.)

Thanks for that bug report.
I hope to fix it for the next release (INN 2.6.1).

Note that nnrpd and innd comply with latest NNTP RFC (3977, 4642, 4643, 
4644 and 6048) but only partially with USEFOR and USEPRO RFC (5536, 
5537).  These last two RFC are the ones we should now focus on.

-- 
Julien ÉLIE

« – Ce n'était pas ma question.
   – C'était p'têt pas vot'question, oui, mais c'est ma
     réponse ! » (Georges Marchais répondant à Alain Duhamel)

Re: Multiple occurences of header fields
#87444
Author: Julien ÉLIE
Date: Tue, 24 May 2016 19:36
115 lines
5785 bytes
Hi all,

>>>> So basically "X-#%-T`!" is a valid header field name. Has
>>>> anyone here already tried to send articles with that unusual
>>>> syntax?
>>
>> INN is far more liberal than that.  It will allow posts with field
>> names which fall outside the allowed range.  (It's not alone in
>> this respect.)
>
> Thanks for that bug report. I hope to fix it for the next release
> (INN 2.6.1).

I've just done a quick audit of how nnrpd enforces the global syntax 
(that is to say not header-specific) given in RFC 5536.  Here are my 
comments.  Do not hesitate to react if you have another point of view.


    o  All agents MUST generate header fields so that at least one space
       immediately follows the ':' separating the header field name and
       the header field body (for compatibility with deployed software,
       including NNTP [RFC3977] servers).

=> This space is currently automatically added by nnrpd, if not already 
present, for standard headers.  I think it is OK to keep that behaviour.
=> However, for non-standard headers, no checks are done.  We should add 
one (note that ":\t" is not allowed, but only ": ").



    o  Every line of a header field body (including the first and any
       that are subsequently folded) MUST contain at least one non-
       whitespace character.

=> This check is currently not done.  We should add it.



    o  Compliant software MUST NOT generate (but MAY accept) header field
       lines of more than 998 octets.  This is the only limit on the
       length of a header field line prescribed by this standard.
       However, specific rules to the contrary may apply in particular
       cases (for example, according to [RFC2047], lines of a header
       field containing encoded words are limited to 76 octets).

=> The check for 998 octets is already done, but not the one for 76 octets!
As INN does not generate such headers, I believe it is OK not to check 
the length of header fields containing encoded words (an injecting agent 
MAY accept them).



    o  The character set for header fields is US-ASCII.  Where the use of
       non-ASCII characters is required, they MUST be encoded using the
       MIME mechanisms defined in [RFC2047] and [RFC2231].

=> This check is currently not done.  I suggest to do nothing about it 
because it will otherwise probably do harm when receiving 
"internationalized" header fields (for instance encoded in UTF-8).



    The following header fields defined in this document do not allow
    <comment>s (i.e., they use FWS rather than CFWS).

    Control
    Distribution
    Followup-To
    Lines
    Newsgroups
    Path
    Supersedes
    Xref

=> I think nnrpd does not check that for Supersedes (and perhaps other 
of these fields).  We should enforce that check, and better, enforce the 
right syntax for these specific headers (Supersedes expects a valid 
message-ID for instance, whereas unstructured text can now be injected).



    An article is said to be conformant to this specification if it
    conforms to the format specified in Section 3 of [RFC5322] and to the
    additional requirements of this specification.

[RFC5322]
    Fields may appear in messages that are otherwise unspecified in this
    document.  They MUST conform to the syntax of an optional-field.
    This is a field name, made up of the printable US-ASCII characters
    except SP and colon, followed by a colon, followed by any text that
    conforms to the unstructured syntax.

    optional-field  =   field-name ":" unstructured CRLF

    field-name      =   1*ftext

    ftext           =   %d33-57 /      ; Printable US-ASCII
                        %d59-126       ; characters not including
                                       ; ":".

    unstructured    =  *WSP VCHAR *( [FWS] VCHAR ) *WSP

    VCHAR           =  %x21-7E         ; visible (printing) characters

=> This check is currently not done at injection time.  I suggest to 
enforce it.  It will fix the issues David reported.

-- 
Julien ÉLIE

« – Ce n'était pas ma question.
   – C'était p'têt pas vot'question, oui, mais c'est ma
     réponse ! » (Georges Marchais répondant à Alain Duhamel)

[OT] humor? Re: Multiple occurences of header fields
#87447
Author: David Ritz
Date: Wed, 25 May 2016 21:58
47 lines
3459 bytes
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--0-758687130-1464213339=:5096
Content-Type: text/plain; CHARSET=UTF-8
Content-Transfer-Encoding: 8BIT
Content-ID: <alpine.OSX.2.20.1605251655551.5096@mako.ath.cx>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday, 24 May 2016 21:36 +0200, 
 in article <ni2afm$96b$1@news.trigofacile.com>, 
 Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> wrote:

> Hi all,

Thanks, Julien,

>    o  Compliant software MUST NOT generate (but MAY accept) header field
>       lines of more than 998 octets.  This is the only limit on the
>       length of a header field line prescribed by this standard.
>       However, specific rules to the contrary may apply in particular
>       cases (for example, according to [RFC2047], lines of a header
>       field containing encoded words are limited to 76 octets).

I found this in the news stream some years ago.  I thought it was 
worth keeping a copy around.  Here, a single article was posted to 923 
newsgroups.

<http://dritz.mako.ath.cx/shaw-xpost.txt>

I guess a single article can be spam: BI=30.381.  %\

- -- 
David Ritz <dritz@mindspring.com>
 Be kind to animals; kiss a shark.

-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAldGIBMACgkQUrwpmRoS3uvi2QCgkHuyrzI2h5Rvtc5hIIfbbGKH
c3IAoPsbFiR+sTJ9uYSUmSDYrq/1EEce
=tYSH
-----END PGP SIGNATURE-----
--0-758687130-1464213339=:5096--

Re: Multiple occurences of header fields
#87446
Author: Michael Baeuerle
Date: Thu, 26 May 2016 09:44
55 lines
3452 bytes
Julien ÉLIE wrote:
> 
> [...]
> I've just done a quick audit of how nnrpd enforces the global syntax 
> (that is to say not header-specific) given in RFC 5536.  Here are my 
> comments.  Do not hesitate to react if you have another point of view.
> [...]
>    o  Compliant software MUST NOT generate (but MAY accept) header field
>       lines of more than 998 octets.  This is the only limit on the
>       length of a header field line prescribed by this standard.
>       However, specific rules to the contrary may apply in particular
>       cases (for example, according to [RFC2047], lines of a header
>       field containing encoded words are limited to 76 octets).
> 
> => The check for 998 octets is already done, but not the one for 76 octets!
> As INN does not generate such headers, I believe it is OK not to check 
> the length of header fields containing encoded words (an injecting 
> agent MAY accept them).

I agree with your opinion. In a very strict sense some text limited by
"=?" and "?=" is not even an encoded-word as long as the posting agent
has not inserted a "MIME-Version" header field to declare this meaning.

And it is never allowed to omit this declaration as defined by RFC2049:

| A mail user agent that is MIME-conformant MUST:
| 
|     (1)   Always generate a "MIME-Version: 1.0" header field in
|           any message it creates.

>    The following header fields defined in this document do not allow
>    <comment>s (i.e., they use FWS rather than CFWS).
> 
>    Control
>    Distribution
>    Followup-To
>    Lines
>    Newsgroups
>    Path
>    Supersedes
>    Xref
> 
> => I think nnrpd does not check that for Supersedes (and perhaps other 
> of these fields).  We should enforce that check, and better, enforce 
> the right syntax for these specific headers (Supersedes expects a valid 
> message-ID for instance, whereas unstructured text can now be injected).

The "Lines" header field is marked obsolete by RFC5536 and there is the
note :

| All agents SHOULD ignore it [...]

Is there a reason for INN to not follow this recommendation?

Re: Multiple occurences of header fields
#87445
Author: Julien ÉLIE
Date: Thu, 26 May 2016 20:40
31 lines
2699 bytes
Hi Michael,

> The "Lines" header field is marked obsolete by RFC5536 and there is the
> note :
>
> | All agents SHOULD ignore it [...]
>
> Is there a reason for INN to not follow this recommendation?

Section 6 (IANA considerations) of RFC5536 marks it as "deprecated", and 
Section 3.3.1 mentions it is "obsolescent".  The Lines: header field 
isn't therefore obsolete yet :)

What is exactly the meaning of "All agents SHOULD *ignore* it"?  Does it 
really mean that the header field is supposed to be removed?  (as 
RFC5536 speaks of *all* agents, it would imply that even innd, as a 
relaying agent, is supposed to remove that header, if seen)
Is it what you are suggesting with your question?

I thought that the header can be present but its value not taken into 
account (for instance, no check for the coherence between its value and 
the reality, not used in overview data...).

-- 
Julien ÉLIE

« – Ce n'était pas ma question.
   – C'était p'têt pas vot'question, oui, mais c'est ma
     réponse ! » (Georges Marchais répondant à Alain Duhamel)

Re: Multiple occurences of header fields
#87448
Author: Michael Baeuerle
Date: Fri, 27 May 2016 11:32
48 lines
3101 bytes
Julien ÉLIE wrote:
> Michael Bäuerle wrote:
> > 
> > The "Lines" header field is marked obsolete by RFC5536 and there is the
> > note :
> > 
> > | All agents SHOULD ignore it [...]
> > 
> > Is there a reason for INN to not follow this recommendation?
> 
> Section 6 (IANA considerations) of RFC5536 marks it as "deprecated", 
> and Section 3.3.1 mentions it is "obsolescent".  The Lines: header 
> field isn't therefore obsolete yet :)
> 
> What is exactly the meaning of "All agents SHOULD *ignore* it"?  Does 
> it really mean that the header field is supposed to be removed?  (as 
> RFC5536 speaks of *all* agents, it would imply that even innd, as a 
> relaying agent, is supposed to remove that header, if seen)
> Is it what you are suggesting with your question?

My suggestion is "not enforce syntax for obsolete header field bodies".

If the "Lines" header field is not obsolete yet (because Section 6 of
RFC5536 makes it only deprecated), my suggestion was based on wrong
assumptions for this field.

I also assumed, that INN no longer use the content of the "Lines" header
field internally.

> I thought that the header can be present but its value not taken into 
> account (for instance, no check for the coherence between its value and 
> the reality, not used in overview data...).

That is what I had in mind too (the syntax of the field body).
"Ignore" in the sense of "don't look at the field body".

Example:

   Lines:-1

IMHO it should only be modified to:

   Lines: -1
         ^
to match the syntax defined for all header fields. But not trying to
repair the invalid field body.

Re: Multiple occurences of header fields
#87449
Author: Julien ÉLIE
Date: Fri, 27 May 2016 19:37
22 lines
2295 bytes
Hi Michael,

>>> The "Lines" header field is marked obsolete by RFC5536 and there is the
>>> note :
>>>
>>> | All agents SHOULD ignore it [...]
>>>
>>> Is there a reason for INN to not follow this recommendation?
[...]
> My suggestion is "not enforce syntax for obsolete header field bodies".

Oh, all right, I misunderstood what you wanted to achieve for the Lines: 
header field body.  I am then OK with your remark.

-- 
Julien ÉLIE

« – Ce n'était pas ma question.
   – C'était p'têt pas vot'question, oui, mais c'est ma
     réponse ! » (Georges Marchais répondant à Alain Duhamel)

Re: Multiple occurences of header fields
#87517
Author: Julien ÉLIE
Date: Thu, 01 Sep 2016 20:03
30 lines
2445 bytes
David and all,

>>>> So basically "X-#%-T`!" is a valid header field name. Has anyone
>>>> here already tried to send articles with that unusual syntax?
>>
>> INN is far more liberal than that.  It will allow posts with field
>> names which fall outside the allowed range.  (It's not alone in this
>> respect.)
>
> Thanks for that bug report.
> I hope to fix it for the next release (INN 2.6.1).

I've just added the following checks at injection time (for INN 2.6.1):
- no white-space-only content lines in a given header field body,
- no control chars (except of course \r\n for folding, and \t),
- header name followed by colon+space and non-empty header field body.

For standard headers, the space after the colon is still added if not 
present (as INN was already doing).


These changes will fix the issue raised in that thread.

-- 
Julien ÉLIE

« Petite annonce : Abeille épouserait frelon. Lune de miel
   assurée. »

Re: Multiple occurences of header fields
#87518
Author: David Ritz
Date: Sat, 03 Sep 2016 21:23
51 lines
3640 bytes
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--0-103946555-1472936479=:4349
Content-Type: text/plain; CHARSET=UTF-8
Content-Transfer-Encoding: 8BIT
Content-ID: <alpine.OSX.2.20.1609031601521.4349@mako.ath.cx>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday, 01 September 2016 22:03 +0200, 
 in article <nqa1h0$f8v$1@news.trigofacile.com>, 
 Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> wrote:

> David and all,

>>>>> So basically "X-#%-T`!" is a valid header field name. Has anyone 
>>>>> here already tried to send articles with that unusual syntax?

>>> INN is far more liberal than that.  It will allow posts with field 
>>> names which fall outside the allowed range.  (It's not alone in 
>>> this respect.)

>> Thanks for that bug report.
>> I hope to fix it for the next release (INN 2.6.1).

> I've just added the following checks at injection time (for INN 2.6.1):
> - no white-space-only content lines in a given header field body,
> - no control chars (except of course \r\n for folding, and \t),
> - header name followed by colon+space and non-empty header field body.

> For standard headers, the space after the colon is still added if 
> not present (as INN was already doing).

> These changes will fix the issue raised in that thread.

Thank you, Julien.

- -- 
David Ritz <dritz@mindspring.com>
 Be kind to animals; kiss a shark.
-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAlfLPz4ACgkQUrwpmRoS3utCEQCglLzg/loorgnSTj/U6WkoBmWd
RT0AoM09ahcKvjIHY8kwr3XBY3XxyB+o
=r+Nx
-----END PGP SIGNATURE-----
--0-103946555-1472936479=:4349--

Re: Multiple occurences of header fields
#87519
Author: Adam H. Kerman
Date: Sun, 04 Sep 2016 15:48
72 lines
4468 bytes
Julien <iulius@nom-de-mon-site.com.invalid> wrote:

>. . . 

>       Compliant software MUST NOT generate (but MAY accept) header field
>       lines of more than 998 octets.  This is the only limit on the
>       length of a header field line prescribed by this standard.
>       However, specific rules to the contrary may apply in particular
>       cases (for example, according to [RFC2047], lines of a header
>       field containing encoded words are limited to 76 octets).

>=> The check for 998 octets is already done, but not the one for 76 octets!
>As INN does not generate such headers, I believe it is OK not to check 
>the length of header fields containing encoded words (an injecting agent 
>MAY accept them).

Once the encoding is added, you can end up displaying a rather short line.
Is it 76 because a longer line is thought to interfere with decoding?

>    o  The character set for header fields is US-ASCII.  Where the use of
>       non-ASCII characters is required, they MUST be encoded using the
>       MIME mechanisms defined in [RFC2047] and [RFC2231].

>=> This check is currently not done.  I suggest to do nothing about it 
>because it will otherwise probably do harm when receiving 
>"internationalized" header fields (for instance encoded in UTF-8).

It sounds like a worthwhile sanity check to perform. It's rarely the author
of the article who absolutely positively has to use characters that must
be encoded but aren't. They end up in the article because he's violating
copyright by copying and pasting an article from the Web and he hasn't run
it through translation first to put it into proper syntax useful on Usenet.

If these full-text quotes were regularly refused, no harm has come to
actual Usenet authors because the author was someone else and he didn't
choose to post to Usenet in the first place.

More often than not, an author writing his own words and posting to Usenet
will get the encoding right because the newsreader does it sanely. These
people usually aren't the problem.

(Yes, yes, there is one well-known exception who uses tons of characters
that must be encoded but refuses to encode them; I refuse to say
its name.)

>    The following header fields defined in this document do not allow
>    <comment>s (i.e., they use FWS rather than CFWS).

>    Control
>    Distribution
>    Followup-To
>    Lines
>    Newsgroups
>    Path
>    Supersedes
>    Xref

>=> I think nnrpd does not check that for Supersedes (and perhaps other 
>of these fields).  We should enforce that check, and better, enforce the 
>right syntax for these specific headers (Supersedes expects a valid 
>message-ID for instance, whereas unstructured text can now be injected).
>. . . 

Does References already get checked for a string of valid Message-IDs too,
or just the Message-ID getting appended? I have no idea how Distribution
could possibly be checked beyond disallowed character; gotta leave that
for some local list of recognized Distributions as that must be customized.

If Control is checked for syntax errors, the error message should be in
the form of laughter and insults.

Re: Multiple occurences of header fields
#87520
Author: Julien ÉLIE
Date: Sun, 04 Sep 2016 19:41
90 lines
5203 bytes
Hi Adam,

>>       Compliant software MUST NOT generate (but MAY accept) header field
>>       lines of more than 998 octets.  This is the only limit on the
>>       length of a header field line prescribed by this standard.
>>       However, specific rules to the contrary may apply in particular
>>       cases (for example, according to [RFC2047], lines of a header
>>       field containing encoded words are limited to 76 octets).
>
>> => The check for 998 octets is already done, but not the one for 76 octets!
>> As INN does not generate such headers, I believe it is OK not to check
>> the length of header fields containing encoded words (an injecting agent
>> MAY accept them).
>
> Once the encoding is added, you can end up displaying a rather short line.
> Is it 76 because a longer line is thought to interfere with decoding?

Section 2 of RFC 2047 gives the following rationale for this limitation:

    An 'encoded-word' may not be more than 75 characters long, including
    'charset', 'encoding', 'encoded-text', and delimiters.  If it is
    desirable to encode more text than will fit in an 'encoded-word' of
    75 characters, multiple 'encoded-word's (separated by CRLF SPACE) may
    be used.

    While there is no limit to the length of a multiple-line header
    field, each line of a header field that contains one or more
    'encoded-word's is limited to 76 characters.

    The length restrictions are included both to ease interoperability
    through internetwork mail gateways, and to impose a limit on the
    amount of lookahead a header parser must employ (while looking for a
    final ?= delimiter) before it can decide whether a token is an
    "encoded-word" or something else.



>>    o  The character set for header fields is US-ASCII.  Where the use of
>>       non-ASCII characters is required, they MUST be encoded using the
>>       MIME mechanisms defined in [RFC2047] and [RFC2231].
>
>> => This check is currently not done.  I suggest to do nothing about it
>> because it will otherwise probably do harm when receiving
>> "internationalized" header fields (for instance encoded in UTF-8).
>
> It sounds like a worthwhile sanity check to perform.

The problem with such a check is that INN would reject current valid 
articles.  We already have UTF-8 chars in wide in a few circumstances, 
especially for internationalized newsgroup names.
There's a sentence about that in RFC 5536, Section 4:  "Note that the 
generation of internationalized <newsgroup-name>s for use in header 
fields is not addressed in this document."



> Does References already get checked for a string of valid Message-IDs too,
> or just the Message-ID getting appended?

INN currently does not check anything about the References: header 
field.  I agree it should do something (list of valid Message-IDs).
However, a news server cannot check whether all Message-IDs corresponds 
to a/ existing articles and b/ articles in the same thread because it 
does not necessarily have the information (notably if an article did not 
reach the news server or if the news server just do not store 
information about articles it just re-feds).



> I have no idea how Distribution could possibly be checked beyond disallowed character

I suggest to just check that it conforms to the expected syntax:

dist-list       =  *WSP dist-name
                       *( [FWS] "," [FWS] dist-name ) *WSP

dist-name       =  ALPHA / DIGIT
                       *( ALPHA / DIGIT / "+" / "-" / "_" )

and that "all" is not present (it is a MUST NOT per RFC 5536, Section 
3.2.4).

-- 
Julien ÉLIE

« – Par Toutatis ! On tire encore sur nous !
   – Nous sommes au dessus de Tyr.
   – Alors tirons-nous vite ! » (Astérix)

Re: Multiple occurences of header fields
#87521
Author: David Ritz
Date: Sun, 04 Sep 2016 20:14
45 lines
3529 bytes
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--0-16514702-1473020022=:56191
Content-Type: text/plain; CHARSET=UTF-8
Content-Transfer-Encoding: 8BIT
Content-ID: <alpine.OSX.2.20.1609041514011.56191@mako.ath.cx>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday, 04 September 2016 21:41 +0200, 
 in article <nqhtcb$8h7$1@news.trigofacile.com>, 
 Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> wrote:

> Adam wrote:

>> Does References already get checked for a string of valid 
>> Message-IDs too, or just the Message-ID getting appended?

> INN currently does not check anything about the References: header 
> field.  I agree it should do something (list of valid Message-IDs). 
> However, a news server cannot check whether all Message-IDs 
> corresponds to a/ existing articles and b/ articles in the same 
> thread because it does not necessarily have the information (notably 
> if an article did not reach the news server or if the news server 
> just do not store information about articles it just re-feds).

Think of the instance where someone might reply to an email message, 
as an Usenet followup in an original thread.  At least one of the 
References whould refer to a message which never appeared on Usenet.  
Such checks do not seem particularly useful.

- -- 
David Ritz <dritz@mindspring.com>
 Be kind to animals; kiss a shark.
-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAlfMgJ8ACgkQUrwpmRoS3utUTQCg0P+bI/nMr5i3KJt17UkxKqup
lhMAn2W8wjC0zdkXOE0/VegXuMcXb+Ub
=JFME
-----END PGP SIGNATURE-----
--0-16514702-1473020022=:56191--

Re: Multiple occurences of header fields
#87522
Author: Adam H. Kerman
Date: Sun, 04 Sep 2016 21:02
106 lines
5722 bytes
Julien <iulius@nom-de-mon-site.com.invalid> wrote:

>Hi Adam,

>>>       Compliant software MUST NOT generate (but MAY accept) header field
>>>       lines of more than 998 octets.  This is the only limit on the
>>>       length of a header field line prescribed by this standard.
>>>       However, specific rules to the contrary may apply in particular
>>>       cases (for example, according to [RFC2047], lines of a header
>>>       field containing encoded words are limited to 76 octets).

>>> => The check for 998 octets is already done, but not the one for 76 octets!
>>> As INN does not generate such headers, I believe it is OK not to check
>>> the length of header fields containing encoded words (an injecting agent
>>> MAY accept them).

>> Once the encoding is added, you can end up displaying a rather short line.
>> Is it 76 because a longer line is thought to interfere with decoding?

>Section 2 of RFC 2047 gives the following rationale for this limitation:

>    An 'encoded-word' may not be more than 75 characters long, including
>    'charset', 'encoding', 'encoded-text', and delimiters.  If it is
>    desirable to encode more text than will fit in an 'encoded-word' of
>    75 characters, multiple 'encoded-word's (separated by CRLF SPACE) may
>    be used.

So a line break in the middle of the encoded word is thought to interfere
with decoding?

>    While there is no limit to the length of a multiple-line header
>    field, each line of a header field that contains one or more
>    'encoded-word's is limited to 76 characters.

>    The length restrictions are included both to ease interoperability
>    through internetwork mail gateways, and to impose a limit on the
>    amount of lookahead a header parser must employ (while looking for a
>    final ?= delimiter) before it can decide whether a token is an
>    "encoded-word" or something else.

Ok, thanks.

>>>    o  The character set for header fields is US-ASCII.  Where the use of
>>>       non-ASCII characters is required, they MUST be encoded using the
>>>       MIME mechanisms defined in [RFC2047] and [RFC2231].

>>> => This check is currently not done.  I suggest to do nothing about it
>>> because it will otherwise probably do harm when receiving
>>> "internationalized" header fields (for instance encoded in UTF-8).

>> It sounds like a worthwhile sanity check to perform.

>The problem with such a check is that INN would reject current valid 
>articles.  We already have UTF-8 chars in wide in a few circumstances, 
>especially for internationalized newsgroup names.
>There's a sentence about that in RFC 5536, Section 4:  "Note that the 
>generation of internationalized <newsgroup-name>s for use in header 
>fields is not addressed in this document."

I guess you could check the other fields.

>> Does References already get checked for a string of valid Message-IDs too,
>> or just the Message-ID getting appended?

>INN currently does not check anything about the References: header 
>field.  I agree it should do something (list of valid Message-IDs).

How about a check for strings in Message-ID syntax?

I shouldn't have suggested "valid", as that's a hell of a lot of processing.

>However, a news server cannot check whether all Message-IDs corresponds 
>to a/ existing articles and b/ articles in the same thread because it 
>does not necessarily have the information (notably if an article did not 
>reach the news server or if the news server just do not store 
>information about articles it just re-feds).

I didn't mean to suggest doing that.

>>I have no idea how Distribution could possibly be checked beyond
>>disallowed character

>I suggest to just check that it conforms to the expected syntax:

>dist-list       =  *WSP dist-name
>                       *( [FWS] "," [FWS] dist-name ) *WSP

>dist-name       =  ALPHA / DIGIT
>                       *( ALPHA / DIGIT / "+" / "-" / "_" )

>and that "all" is not present (it is a MUST NOT per RFC 5536, Section 
>3.2.4).

That makes good sense.

Here's something I don't know: How does a News server or newsreader
learn of valid distributions? Is there a a file that a newsreader
would typically download?

Or was the assumption all along that every user would just know
what the distributions were?

I can't recall the last time I saw an article that used the Distribution
header.

Re: Multiple occurences of header fields
#87523
Author: Michael Bäuerle
Date: Mon, 05 Sep 2016 12:38
29 lines
2135 bytes
Adam H. Kerman wrote:
>Julien <iulius@nom-de-mon-site.com.invalid> wrote:
>>
>>Section 2 of RFC 2047 gives the following rationale for this limitation:
>>
>>   An 'encoded-word' may not be more than 75 characters long, including
>>   'charset', 'encoding', 'encoded-text', and delimiters.  If it is
>>   desirable to encode more text than will fit in an 'encoded-word' of
>>   75 characters, multiple 'encoded-word's (separated by CRLF SPACE) may
>>   be used.
>
>So a line break in the middle of the encoded word is thought to interfere
>with decoding?

Yes. If an 'encoded-word' must be split to multiple lines, two
independent 'encoded-word's must be used instead.

Examples that decode to the same content "[...] TestTestTest [...]":

[...] =?US-ASCII?Q?TestTestTest?= [...]

[...] =?US-ASCII?Q?TestTest?=
 =?US-ASCII?Q?Test?= [...]

[...] =?US-ASCII?Q?TestTest?= =?US-ASCII?Q?Test?= [...]

Whitespace between 'encoded-word' tokens is semantically ignored.

Re: Multiple occurences of header fields
#87524
Author: Adam H. Kerman
Date: Mon, 05 Sep 2016 18:57
32 lines
2347 bytes
Michael <michael.baeuerle@gmx.net> wrote:
>Adam H. Kerman wrote:
>>Julien <iulius@nom-de-mon-site.com.invalid> wrote:

>>>Section 2 of RFC 2047 gives the following rationale for this limitation:

>>>   An 'encoded-word' may not be more than 75 characters long, including
>>>   'charset', 'encoding', 'encoded-text', and delimiters.  If it is
>>>   desirable to encode more text than will fit in an 'encoded-word' of
>>>   75 characters, multiple 'encoded-word's (separated by CRLF SPACE) may
>>>   be used.

>>So a line break in the middle of the encoded word is thought to interfere
>>with decoding?

>Yes. If an 'encoded-word' must be split to multiple lines, two
>independent 'encoded-word's must be used instead.

>Examples that decode to the same content "[...] TestTestTest [...]":

>[...] =?US-ASCII?Q?TestTestTest?= [...]

>[...] =?US-ASCII?Q?TestTest?=
> =?US-ASCII?Q?Test?= [...]

>[...] =?US-ASCII?Q?TestTest?= =?US-ASCII?Q?Test?= [...]

>Whitespace between 'encoded-word' tokens is semantically ignored.

Thank you Michael and Julien.

Re: Multiple occurences of header fields
#87525
Author: Julien ÉLIE
Date: Mon, 05 Sep 2016 20:49
113 lines
5972 bytes
Hi Adam,

>>>> => This check is currently not done.  I suggest to do nothing about it
>>>> because it will otherwise probably do harm when receiving
>>>> "internationalized" header fields (for instance encoded in UTF-8).
>>
>> The problem with such a check is that INN would reject current valid
>> articles.  We already have UTF-8 chars in wide in a few circumstances,
>> especially for internationalized newsgroup names.
>
> I guess you could check the other fields.

If a deployed version of a news server rejects articles containing UTF-8 
for instance in the Subject: header field, it will be problematic when 
(and if) we standardize internationalized Netnews headers.
Such deployed versions would incorrectly reject those articles.

See for instance RFC 6532 that already does that for Email headers. 
We'll probably do a similar thing one day for Netnews.

Abstract of RFC 6532:

    Internet mail was originally limited to 7-bit ASCII.  MIME added
    support for the use of 8-bit character sets in body parts, and also
    defined an encoded-word construct so other character sets could be
    used in certain header field values.  However, full
    internationalization of electronic mail requires additional
    enhancements to allow the use of Unicode, including characters
    outside the ASCII repertoire, in mail addresses as well as direct use
    of Unicode in header fields like "From:", "To:", and "Subject:",
    without requiring the use of complex encoded-word constructs.  This
    document specifies an enhancement to the Internet Message Format and
    to MIME that allows use of Unicode in mail addresses and most header
    field content.



>> INN currently does not check anything about the References: header
>> field.
>
> How about a check for strings in Message-ID syntax?

Are there still such Message-IDs generated nowadays?

I know that Appendix A.2 of RFC 3977 mentions them:

    This specification states that message-ids are the same if and only
    if they consist of the same sequence of octets.  Other specifications
    may define two different sequences as being equal because they are
    putting an interpretation on particular characters.  RFC 2822
    [RFC2822] has a concept of "quoted" and "escaped" characters.  It
    therefore considers the three message-ids:

       <ab.cd@example.com>
       <"ab.cd"@example.com>
       <"ab.\cd"@example.com>

    as being identical.  Therefore, an NNTP implementation handing email
    articles must ensure that only one of these three appears in the
    protocol and that the other two are converted to it as and when
    necessary, such as when a client checks the results of a NEWNEWS
    command against an internal database of message-ids.  Note that
    RFC 1036 [RFC1036] never treats two different strings as being
    identical.  Its successor (as of the time of writing) restricts the
    syntax of message-ids so that, whenever RFC 2822 would treat two
    strings as equivalent, only one of them is valid (in the above
    example, only the first string is valid).



I think we can check that for the Message-ID: header field, as INN 
already does (nnrpd will reject <"ab.cd"@example.com>).  I am unsure it 
will change anything to enforce that in the References: header field. 
It does no harm if a quoted message-ID is mentioned there, doesn't it?
I fear enforcing that rules for the References: header field would be 
counter-productive and prevent people from actually posting articles. 
They usually cannot change that automatically added header field to 
their post.

If I post a message with an invalid message-ID, you wouldn't be able to 
answer me!



> Here's something I don't know: How does a News server or newsreader
> learn of valid distributions? Is there a a file that a newsreader
> would typically download?

I do not know such a file that a news reader or a news server would 
download.
A news admin may provide a list of distributions he wishes to advertise, 
but there is no obligation.  See how LIST DISTRIBUTIONS and LIST 
DISTRIB.PATS work (RFC 6048).

LIST DISTRIBUTIONS
215 Distributions in form "distribution description"
fr           Local to France.
trigofacile  Local distribution.
..

LIST DISTRIB.PATS
215 Default distributions in form "weight:group-pattern:distribution"
10:trigofacile.test:trigofacile
..

-- 
Julien ÉLIE

« – Par Toutatis ! On tire encore sur nous !
   – Nous sommes au dessus de Tyr.
   – Alors tirons-nous vite ! » (Astérix)

Re: Multiple occurences of header fields
#87526
Author: Michael Bäuerle
Date: Tue, 06 Sep 2016 09:42
42 lines
2979 bytes
Julien ÉLIE wrote:
> Adam H. Kerman wrote:
> > Julien ÉLIE wrote:
> > > 
> > > [...]
> > > The problem with such a check is that INN would reject current valid
> > > articles.  We already have UTF-8 chars in wide in a few circumstances,
> > > especially for internationalized newsgroup names.
> > 
> > I guess you could check the other fields.
> 
> If a deployed version of a news server rejects articles containing 
> UTF-8 for instance in the Subject: header field, it will be problematic 
> when (and if) we standardize internationalized Netnews headers.
> Such deployed versions would incorrectly reject those articles.
> 
> See for instance RFC 6532 that already does that for Email headers. 
> We'll probably do a similar thing one day for Netnews.

I agree for header fields like "Subject" (that are not relevant for the
network distribution of the article).
But is this also true for header fields like "Newsgroups"?

Potential problems with Unicode can be:
1) Ambiguity (canonical equivalence)
2) Invalid Unicode codepoints
3) Invalid sequences in UTF-8 transformation format

Checking for 1) requires normalization. And because Normal Form C is
only a "SHOULD" in RFC5198 (Chapter 2, Paragraph 4), articles using
wrong normalization should pass anyway.

Checking for 2) is likely a bad idea in general (future articles may
legally use codepoints that are not assigned yet).

But checking for 3) would be easy and IMHO has no obvious drawbacks
(that the successor of ASCII would be something else than UTF-8 is
very unlikely).
Because every US-ASCII string is a valid UTF-8 string too, all such
strings would automatically pass this potential check too.

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads