fix percent encoding on control chars

This commit is contained in:
Simon Cruanes 2024-12-06 14:42:17 -05:00
parent 1c61c39172
commit 1318d46efa
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -6,7 +6,8 @@ let percent_encode ?(skip = fun _ -> false) s =
| ( ' ' | '!' | '"' | '#' | '$' | '%' | '&' | '\'' | '(' | ')' | '*' | '+'
| ',' | '/' | ':' | ';' | '=' | '?' | '@' | '[' | ']' | '~' ) as c ->
Printf.bprintf buf "%%%X" (Char.code c)
| c when Char.code c > 127 -> Printf.bprintf buf "%%%X" (Char.code c)
| c when Char.code c < 32 || Char.code c > 127 ->
Printf.bprintf buf "%%%X" (Char.code c)
| c -> Buffer.add_char buf c)
s;
Buffer.contents buf