[backend] Escape URLs to fix html output

Reviewed By: jeremydubreil

Differential Revision: D4707377

fbshipit-source-id: cbbccdc
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot
parent 3e6ff023a7
commit 8d5be14e9c

@ -174,8 +174,9 @@ struct
let pos_str = match pos with
| None -> ""
| Some s -> "#" ^ s in
let escaped_path = List.map ~f:Escape.escape_url path in
let link_str =
(DB.filename_to_string (DB.Results_dir.path_to_filename DB.Results_dir.Rel path))
(DB.filename_to_string (DB.Results_dir.path_to_filename DB.Results_dir.Rel escaped_path))
^ ".html"
^ pos_str in
let name_str = match name with

@ -44,6 +44,29 @@ let escape_xml s =
| _ -> None in
escape_map map s
let escape_url s =
let map = function
| '!' -> Some "%21"
| '#' -> Some "%23"
| '$' -> Some "%24"
| '&' -> Some "%26"
| '\'' -> Some "%27"
| '(' -> Some "%28"
| ')' -> Some "%29"
| '*' -> Some "%2A"
| '+' -> Some "%2B"
| ',' -> Some "%2C"
| '/' -> Some "%2F"
| ':' -> Some "%3A"
| ';' -> Some "%3B"
| '=' -> Some "%3D"
| '?' -> Some "%3F"
| '@' -> Some "%40"
| '[' -> Some "%5B"
| ']' -> Some "%5D"
| _ -> None in
escape_map map s
let escape_dotty s =
let map = function
| '"' -> Some "\\\""

@ -27,5 +27,8 @@ val escape_path : string -> string
(** escape a string to be used in an xml file *)
val escape_xml : string -> string
val escape_url : string -> string
(** escape a string to be used as a file name *)
val escape_filename : string -> string

Loading…
Cancel
Save