12
12
(* library, see the COPYING file for more information. *)
13
13
(* ****************************************************************************)
14
14
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
+
15
26
{
16
27
open Format822_parser
17
28
@@ -29,19 +40,20 @@ let upper_letter = [ 'A' - 'Z' ]
29
40
let letter = lower_letter | upper_letter
30
41
let digit = [ '0' - '9' ]
31
42
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)
33
47
34
48
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 }
44
57
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