Commit 90d80242 authored by Guillaume Melquiond's avatar Guillaume Melquiond

Extend the range of allowed characters in the fragment and use '%' instead of '.' for escaping.

RFC 3986 states that the allowed characters are:

   fragment      = *( pchar / "/" / "?" )
   pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
   pct-encoded   = "%" HEXDIG HEXDIG
   unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
   sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
                 / "*" / "+" / "," / ";" / "="
parent 4be7c467
......@@ -37,8 +37,8 @@ let output_file fname =
let tag_allowed_char =
let tbl = Array.make 256 false in
let s = "-_:" in (* '.' is removed so as to be used as an escape char below *)
for i = 0 to String.length s - 1 do tbl.(Char.code s.[i]) <- true done;
let s = "-._~!$'()*+,;=:@/?" in (* while & is allowed in uri, it has to be escaped in html *)
String.iter (fun c -> tbl.(Char.code c) <- true) s;
let span m n = for i = Char.code m to Char.code n do tbl.(i) <- true done in
span 'A' 'Z';
span 'a' 'z';
......@@ -50,7 +50,7 @@ let pp_tag_escape =
String.iter (fun c ->
if tag_allowed_char c then Format.fprintf fmt "%c" c else
let c = Char.code c in
Format.fprintf fmt ".%c%c" hex.[c / 16] hex.[c mod 16]) s
Format.fprintf fmt "%%%c%c" hex.[c / 16] hex.[c mod 16]) s
let pp_tag fmt s l =
Format.fprintf fmt "%a_%d" pp_tag_escape s l
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment