From e5216d26f14cef26d8733dd2555b562c7fdd5f35 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Mon, 12 Jan 2015 20:00:10 +0100 Subject: [PATCH] escape entities when outputting xml --- genxml.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/genxml.ml b/genxml.ml index 9d4999d8a89..69e20db9df3 100644 --- a/genxml.ml +++ b/genxml.ml @@ -145,7 +145,7 @@ and gen_field att f = | Var v -> let att = try begin match Meta.get Meta.Value f.cf_meta with - | (_,[e],_) -> ("expr",String.concat "'" (ExtString.String.nsplit (Ast.s_expr e) "\"")) :: att + | (_,[e],_) -> ("expr",Ast.s_expr e) :: att | _ -> att end with Not_found -> @@ -262,8 +262,11 @@ let rec gen_type_decl com pos t = let this = [node "this" [] [gen_type a.a_this]] in node "abstract" (gen_type_params pos a.a_private (tpath t) a.a_params a.a_pos m) (sub @ this @ super @ doc @ meta @ impl) +let escape_entities s = + Xml.to_string (Xml.PCData s) + let att_str att = - String.concat "" (List.map (fun (a,v) -> Printf.sprintf " %s=\"%s\"" a v) att) + String.concat "" (List.map (fun (a,v) -> Printf.sprintf " %s=\"%s\"" a (escape_entities v)) att) let rec write_xml ch tabs x = match x with