Article View: news.software.nntp
Article #87819[canlock-hp] Header parsers for RFC 8315
From: 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>
Technical Details
Message-ID:
<AABbAEjfH2MAAA+x.A1.flnews@Server4.micha.freeshell.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.(19219).mbox.7z!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <AABbAEjfH2MAAA+x.A1.flnews@Server4.micha.freeshell.org> Subject: [canlock-hp] Header parsers for RFC 8315 Date: Sat, 19 May 2018 15:55:11 -0000 From: Michael Bäuerle <michael.baeuerle@gmx.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.(19219).mbox.7z!not-for-mail Newsgroups: news.software.nntp Lines: 54 Mime-Version: 1.0 X-Trace: individual.net XJ4dWdZBHa7Dac01KfVa5QQNDHwEmfaH7uKq4VgJoRN40ncI5Q X-Orig-Path: not-for-mail Cancel-Lock: sha256:HwIa1CW8afuyMjLnygrTQW1s2giVVq9D4wmVLfHD8IY= sha1:o7nSM2YYkfQ9AyZFsmoQdlDt+2s= Injection-Date: Sat, 19 May 2018 15:55:11 -0000 User-Agent: flnews/0.15 (for HP-UX) X-Received-Bytes: 2974 X-Received-Body-CRC: 4041224371