1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
open Core
module RFC2045 = struct
module Token = struct
include (Mimestring.Case_insensitive : Mimestring.S)
let is_valid str =
(not (String.is_empty str))
&& String.for_all str ~f:(function
| '('
| ')'
| '<'
| '>'
| '@'
| ','
| ';'
| ':'
| '\\'
| '"'
| '/'
| '['
| ']'
| '?'
| '=' -> false
| '\033' .. '\126' -> true
| _ -> false)
;;
let is_valid_or_quote str = if is_valid str then str else Mimestring.quote str
end
end