diff --git a/sw/lib/ocaml/extXml.ml b/sw/lib/ocaml/extXml.ml index 5171771cfb..f5cfeae2cd 100644 --- a/sw/lib/ocaml/extXml.ml +++ b/sw/lib/ocaml/extXml.ml @@ -229,3 +229,14 @@ let parse_file = fun ?(noprovedtd = false) file -> let digest = fun xml -> Digest.string (Xml.to_string xml) + +let predefined_general_entities = + [ Str.regexp "&", "&"; + Str.regexp """, "\"" ] + +let display_entities = fun s -> + List.fold_right + (fun (regexp, displayed_as) r -> Str.global_replace regexp displayed_as r) + predefined_general_entities + s + diff --git a/sw/lib/ocaml/extXml.mli b/sw/lib/ocaml/extXml.mli index 7687add139..92c4fd7b20 100644 --- a/sw/lib/ocaml/extXml.mli +++ b/sw/lib/ocaml/extXml.mli @@ -69,3 +69,4 @@ val parse_file : ?noprovedtd:bool -> string -> Xml.xml val digest : Xml.xml -> Digest.t (** Returns the MD5 digest of an XML tree (c.f. Digest module of std library) *) +val display_entities : string -> string diff --git a/sw/lib/ocaml/xmlCom.ml b/sw/lib/ocaml/xmlCom.ml index 99dfa6a6e6..9eb1dc22b0 100644 --- a/sw/lib/ocaml/xmlCom.ml +++ b/sw/lib/ocaml/xmlCom.ml @@ -73,11 +73,14 @@ let parse_file = fun file -> | D, '"' -> copy_and_continue D' | D, _ -> copy_and_continue D + (* Inside a quoted string *) | D', '"' -> copy_and_continue D - | D', '\\' -> copy_and_continue D'' + | D', '\\' -> automata D'' | D', _ -> copy_and_continue D' - | D'', _ -> copy_and_continue D' + (* Inside a quoted string, just after a \ (backslash) *) + | D'', '"' -> Buffer.add_string buff """; automata D' + | D'', _ -> Buffer.add_char buff '\\'; copy_and_continue D' | E, '>' -> replace_and_continue A | E, _ -> copy_and_continue D diff --git a/sw/tools/gen_airframe.ml b/sw/tools/gen_airframe.ml index c79240802b..feef4d87c8 100644 --- a/sw/tools/gen_airframe.ml +++ b/sw/tools/gen_airframe.ml @@ -70,7 +70,7 @@ let parse_element = fun prefix s -> match Xml.tag s with "define" -> begin try - define (prefix^ExtXml.attrib s "name") (ExtXml.attrib s "value"); + define (prefix^ExtXml.attrib s "name") (ExtXml.display_entities (ExtXml.attrib s "value")); define_integer (prefix^(ExtXml.attrib s "name")) (ExtXml.float_attrib s "value") (ExtXml.int_attrib s "integer"); with _ -> (); end