Thread View: news.software.nntp
5 messages
5 total messages
Started by Michael Bäuerle
Sat, 19 May 2018 15:55
[canlock-hp] Header parsers for RFC 8315
Author: Michael Bäuerle
Date: Sat, 19 May 2018 15:55
Date: Sat, 19 May 2018 15:55
56 lines
3164 bytes
3164 bytes
In the german hierarchy a problem with folded Cancel-Lock header fields was discussed (not processed correctly by a server that uses libcanlock [1] for verification of Cancel-Keys). The syntax defined in RFC 8315 allows folding and comments in Cancel-Lock header fields, but articles that use it are not trivial to parse. I have tried to fill the gap from a raw article header in canonical format to the canlock command line utility with a header parser utility. This attempt resulted in two utilities. One parser to extract the header field from the article and unfold it (canlock-mhp). And a second parser to process the header field itself (canlock-hfp): <http://micha.freeshell.org/canlock-hp/index.html> I have splitted the job for the following reasons: - canlock-mhp should be error tolerant This part should work even if the article is broken, as long as the header and the requested header field can still be identified. - canlock-hfp uses state machines generated by lex and yacc The grammar definitions are much easier to write if they only have to cover the syntax of particular header fields. Note: In Version 0.0.0 the canlock-mhp utility is not strictly RFC 5322 compliant because it cannot process NUL control characters (that are required by the obsolete syntax). Instead every NUL is replaced with a SUB control character as documented in the man page. Because NUL control characters are only allowed in comments for the header fields defined by RFC 8315 (and canlock-hfp ignores comments), this would only be a problem if canlock-mhp is not used for the intended purpose. Example: | | $ printf "Cancel-kEy: (\134\0)%s\r\n %s\r\n\r\nBody\r\n" "sHa256:XXX==" "(sha224:wxyz)ShA512:aaaBBBcccDDDeeeFFF" | canlock-mhp -f "Cancel-Key" | canlock-hfp | sha256:XXX== | sha512:aaaBBBcccDDDeeeFFF "\134\0" is Backslash-NUL in octal representation (obs-qp from [2]). "\r\n\r\n" is the empty line that marks the end of the header. The example input data in a more human readable form: | | Cancel-kEy: (\<NUL>)sHa256:XXX== | (sha224:wxyz)ShA512:aaaBBBcccDDDeeeFFF | | Body ______________ [1] <http://micha.freeshell.org/libcanlock/index.html> [2] <https://tools.ietf.org/html/rfc5322#section-4.1>
Re: [canlock-hp] Header parsers for RFC 8315
Author: Julien ÉLIE
Date: Sat, 19 May 2018 20:21
Date: Sat, 19 May 2018 20:21
77 lines
3979 bytes
3979 bytes
Hi Michael,
> Because NUL control characters are only allowed in comments for the
> header fields defined by RFC 8315 (and canlock-hfp ignores comments),
> this would only be a problem if canlock-mhp is not used for the
> intended purpose.
Note that RFC 3977 (NNTP) does not allow NUL control characters:
A multi-line data block is used in certain commands and responses.
It MUST adhere to the following rules:
1. The block consists of a sequence of zero or more "lines", each
being a stream of octets ending with a CRLF pair. Apart from
those line endings, the stream MUST NOT include the octets NUL,
LF, or CR.
And also:
article = 1*header CRLF body
header = header-name ":" [CRLF] SP header-content CRLF
header-content = *(S-CHAR / [CRLF] WS)
body = *(*B-CHAR CRLF)
S-CHAR = P-CHAR
P-CHAR = A-CHAR / UTF8-non-ascii
A-CHAR = %x21-7E
UTF8-non-ascii = UTF8-2 / UTF8-3 / UTF8-4
UTF8-2 = %xC2-DF UTF8-tail
UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2UTF8-tail /
%xED %x80-9F UTF8-tail / %xEE-EF 2UTF8-tail
UTF8-4 = %xF0 %x90-BF 2UTF8-tail / %xF1-F3 3UTF8-tail /
%xF4 %x80-8F 2UTF8-tail
UTF8-tail = %x80-BF
B-CHAR = CTRL / TAB / SP / %x21-FF
CTRL = %x01-08 / %x0B-0C / %x0E-1F
And according to RFC 5536 (USEFOR):
The syntax allowed for Netnews
article headers is a strict subset of the Internet Message Format
headers, making all headers compliant with this specification
inherently compliant with [RFC5322]. Note however that the converse
is not guaranteed to be true in all cases.
[...]
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].
So, basically, compliant NNTP implementations of RFC 8315 (Cancel-Lock)
do not allow NUL control characters.
> | $ printf "Cancel-kEy: (\134\0)%s\r\n %s\r\n\r\nBody\r\n" "sHa256:XXX==" "(sha224:wxyz)ShA512:aaaBBBcccDDDeeeFFF" | canlock-mhp -f "Cancel-Key" | canlock-hfp
> | sha256:XXX==
> | sha512:aaaBBBcccDDDeeeFFF
>
> "\134\0" is Backslash-NUL in octal representation (obs-qp from [2]).
This is not a valid Cancel-Key header field.
I therefore believe that the canlock-mhp utility does not need strict
compatibility with RFC 5322 (it is OK if your Version 0.0.0 cannot
process NUL control characters).
--
Julien ÉLIE
« Tous les trois mois, les Gaulois paieront les thermes. »
(Aplusbégalix)
Re: [canlock-hp] Header parsers for RFC 8315
Author: Michael Bäuerle
Date: Sun, 20 May 2018 09:26
Date: Sun, 20 May 2018 09:26
67 lines
3762 bytes
3762 bytes
Julien ÉLIE wrote: > Michael Bäuerle wrote: > > > > Because NUL control characters are only allowed in comments for the > > header fields defined by RFC 8315 (and canlock-hfp ignores comments), > > this would only be a problem if canlock-mhp is not used for the > > intended purpose. > > Note that RFC 3977 (NNTP) does not allow NUL control characters: > > A multi-line data block is used in certain commands and responses. > It MUST adhere to the following rules: > > 1. The block consists of a sequence of zero or more "lines", each > being a stream of octets ending with a CRLF pair. Apart from > those line endings, the stream MUST NOT include the octets NUL, > LF, or CR. > [...] I have not checked against RFC 3977 because the parser should not depend on the transport protocol, only on the content. > And according to RFC 5536 (USEFOR): > > The syntax allowed for Netnews > article headers is a strict subset of the Internet Message Format > headers, making all headers compliant with this specification > inherently compliant with [RFC5322]. Note however that the converse > is not guaranteed to be true in all cases. > [...] > 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]. Because NUL is an US-ASCII character, in the sense of RFC 20, I think this is not the reason that makes it noncompliant. But this paragraph from Section 2: | | 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: | [No exception for NUL] > So, basically, compliant NNTP implementations of RFC 8315 (Cancel-Lock) > do not allow NUL control characters. Agreed. > > | $ printf "Cancel-kEy: (\134\0)%s\r\n %s\r\n\r\nBody\r\n" "sHa256:XXX==" "(sha224:wxyz)ShA512:aaaBBBcccDDDeeeFFF" | canlock-mhp -f "Cancel-Key" | canlock-hfp > > | sha256:XXX== > > | sha512:aaaBBBcccDDDeeeFFF > > > > "\134\0" is Backslash-NUL in octal representation (obs-qp from [2]). > > This is not a valid Cancel-Key header field. But only because of <obs-qp>, the non-Base64 data should match on <obs-c-key-string>. Or do you mean something else? > I therefore believe that the canlock-mhp utility does not need strict > compatibility with RFC 5322 (it is OK if your Version 0.0.0 cannot > process NUL control characters). I should redefine canlock-mhp to only be an RFC 5536 parser, to reduce its scope to news articles.
Re: [canlock-hp] Header parsers for RFC 8315
Author: Julien ÉLIE
Date: Sun, 20 May 2018 13:54
Date: Sun, 20 May 2018 13:54
41 lines
2588 bytes
2588 bytes
Hi Michael, >> Note that RFC 3977 (NNTP) does not allow NUL control characters: > > I have not checked against RFC 3977 because the parser should not > depend on the transport protocol, only on the content. OK. >> This is not a valid Cancel-Key header field. > > But only because of <obs-qp>, the non-Base64 data should match on > <obs-c-key-string>. Or do you mean something else? No, that was what I meant. >> I therefore believe that the canlock-mhp utility does not need strict >> compatibility with RFC 5322 (it is OK if your Version 0.0.0 cannot >> process NUL control characters). > > I should redefine canlock-mhp to only be an RFC 5536 parser, to reduce > its scope to news articles. That's indeed what I meant and suggested, but provided the wrong argument. You're right that this paragraph, from RFC 5536, is the expected argument to highlight: > | 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: > | [No exception for NUL] -- Julien ÉLIE « – C'est quoi la vesperna ? – C'est du latin de cuisine imbécile ! » (Astérix)
Re: [canlock-hp] Header parsers for RFC 8315
Author: Michael Bäuerle
Date: Mon, 21 May 2018 13:48
Date: Mon, 21 May 2018 13:48
27 lines
2108 bytes
2108 bytes
Julien ÉLIE wrote: > Michael Bäuerle wrote: > > Julien ÉLIE wrote: > > > > > > [...] > > > I therefore believe that the canlock-mhp utility does not need strict > > > compatibility with RFC 5322 (it is OK if your Version 0.0.0 cannot > > > process NUL control characters). > > > > I should redefine canlock-mhp to only be an RFC 5536 parser, to reduce > > its scope to news articles. > > That's indeed what I meant and suggested, but provided the wrong argument. > You're right that this paragraph, from RFC 5536, is the expected > argument to highlight: > > > | 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: > > | [No exception for NUL] Thanks for your comments. There is now version 0.0.1 available with updated documentation: <http://micha.freeshell.org/canlock-hp/index.html>
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