mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-20 11:28:58 +08:00
bug fixed: " handling
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user