From 8b268bd8970e183d765850fac09386cc2d32dadc Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Tue, 10 Feb 2015 14:22:14 +0100 Subject: [PATCH] generator: add a simple HTML escaping function --- generator/utils.ml | 8 +++++++- generator/utils.mli | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/generator/utils.ml b/generator/utils.ml index b24ba8c9e..3a6208450 100644 --- a/generator/utils.ml +++ b/generator/utils.ml @@ -360,4 +360,10 @@ let args_of_optargs optargs = | OInt64 n -> Int64 n | OString n -> String n | OStringList n -> StringList n - ) optargs; + ) optargs + +let html_escape text = + let text = replace_str text "&" "&" in + let text = replace_str text "<" "<" in + let text = replace_str text ">" ">" in + text diff --git a/generator/utils.mli b/generator/utils.mli index 5fd40ce20..e0f30c3e4 100644 --- a/generator/utils.mli +++ b/generator/utils.mli @@ -131,3 +131,6 @@ val spaces : int -> string val args_of_optargs : Types.optargs -> Types.args (** Convert a list of optargs into an equivalent list of args *) + +val html_escape : string -> string +(** Escape a text for HTML display. *)