Skip to content

Commit 48d2194

Browse files
author
Pietro Abate
committed
Fix Debian bug #811569
the 822 lexer now follows the debian specification regarding field names: "The field name is composed of US-ASCII characters excluding control characters, space, and colon (i.e., characters in the ranges 33-57 and 59-126, inclusive). Field names must not begin with the comment character, #, nor with the hyphen character, -. "
1 parent 60b90dc commit 48d2194

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

common/format822_lexer.mll

+25-13
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
(* library, see the COPYING file for more information. *)
1313
(*****************************************************************************)
1414

15+
(*
16+
Debian Policy : https://www.debian.org/doc/debian-policy/ch-controlfields.html
17+
18+
Each paragraph consists of a series of data fields. Each field consists of the
19+
field name followed by a colon and then the data/value associated with that
20+
field. The field name is composed of US-ASCII characters excluding control
21+
characters, space, and colon (i.e., characters in the ranges 33-57 and 59-126,
22+
inclusive). Field names must not begin with the comment character, #, nor with
23+
the hyphen character, -.
24+
*)
25+
1526
{
1627
open Format822_parser
1728

@@ -29,19 +40,20 @@ let upper_letter = [ 'A' - 'Z' ]
2940
let letter = lower_letter | upper_letter
3041
let digit = [ '0' - '9' ]
3142
let blank = [ ' ' '\t' ]
32-
let ident = (letter | digit | '-')+
43+
let ident = ( [ '!' - '9'] | [';' - '~' ] )+
44+
let identnosharphypen = ( '!' | '"' | [ '$' - ',' ] | [ '.' - '9'] | [';' - '~' ] )
45+
(* conform to the Debian Policy *)
46+
let fieldname = (identnosharphypen ident)
3347

3448
rule token_822 = parse
35-
| "-----BEGIN PGP SIGNED MESSAGE-----" { PGPHEAD }
36-
| "-----BEGIN PGP SIGNATURE-----" { pgpsignature lexbuf }
37-
| (ident as field) ':' blank*
38-
([^'\n']* as rest) { FIELD(field, (get_range lexbuf, rest)) }
39-
| blank ([^'\n']* as rest) { CONT(get_range lexbuf, rest) }
40-
(* | '#' [^'\n']* ('\n'|eof) { token_822 lexbuf } *)
41-
| blank* '\n' { Lexing.new_line lexbuf; BLANKLINE }
42-
| eof { EOF }
43-
| _ as c { raise_error lexbuf c }
49+
| "-----BEGIN PGP SIGNED MESSAGE-----" { PGPHEAD }
50+
| "-----BEGIN PGP SIGNATURE-----" { pgpsignature lexbuf }
51+
| '#' [^'\n']* ('\n'|eof) { token_822 lexbuf }
52+
| (fieldname as field) ':' blank* ([^'\n']* as rest) { FIELD(field, (get_range lexbuf, rest)) }
53+
| blank ([^'\n']* as rest) { CONT(get_range lexbuf, rest) }
54+
| blank* '\n' { Lexing.new_line lexbuf; BLANKLINE }
55+
| eof { EOF }
56+
| _ as c { raise_error lexbuf c }
4457
and pgpsignature = parse
45-
| "-----END PGP SIGNATURE-----" { token_822 lexbuf }
46-
| _ { pgpsignature lexbuf }
47-
58+
| "-----END PGP SIGNATURE-----" { token_822 lexbuf }
59+
| _ { pgpsignature lexbuf }

0 commit comments

Comments
 (0)