OCaml implementation of the Mozilla Public Suffix service

fix

+8 -6
+2 -3
gen/gen_psl.ml
··· 82 82 |> List.rev 83 83 |> List.filter (fun s -> s <> "") 84 84 |> List.map (fun label -> 85 - match Punycode.encode_label label with 86 - | Ok encoded -> String.lowercase_ascii encoded 87 - | Error _ -> String.lowercase_ascii label) 85 + try String.lowercase_ascii (Punycode.encode_label label) 86 + with Punycode.Error _ -> String.lowercase_ascii label) 88 87 in 89 88 if labels = [] then None else Some { labels; rule_type; section } 90 89
+6 -3
lib/publicsuffix.ml
··· 152 152 if domain = "" then Error Empty_domain 153 153 else 154 154 (* Convert IDN to ASCII (Punycode) *) 155 - match Punycode_idna.to_ascii domain with 156 - | Error e -> 157 - let msg = Format.asprintf "%a" Punycode_idna.pp_error e in 155 + match 156 + try Ok (Punycode_idna.to_ascii domain) 157 + with Punycode_idna.Error e -> 158 + let msg = Format.asprintf "%a" Punycode_idna.pp_error_reason e in 158 159 Error (Punycode_error msg) 160 + with 161 + | Error e -> Error e 159 162 | Ok ascii_domain -> 160 163 (* Convert to lowercase and split into labels *) 161 164 let ascii_lower = String.lowercase_ascii ascii_domain in